[your code here] Pure RPN calculator

Patrick Schluter via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 26 10:28:46 PDT 2017


On Wednesday, 26 July 2017 at 17:12:00 UTC, Mike Wey wrote:
> On 26-07-17 16:40, Iakh wrote:
>> On Wednesday, 26 July 2017 at 09:46:45 UTC, Timon Gehr wrote:
>>>>      readln.split.fold!((stack,op){
>>>>          switch(op){
>>>>              static foreach(c;"+-*/") case [c]:
>>>>                  return stack[0..$-2]~mixin("stack[$-2] 
>>>> "~c~" stack[$-1]");
>>>>              default: return stack~op.to!real;
>>>>          }
>>>>      })((real[]).init).writeln;
>> 
>> What does "case [c]:" mean?
>> 
>
> In the static foreach c is a `immutable char` by putting it 
> between [ and ] you create an array of immutable characters 
> (string).

That's why some comments in the code would go a long way in 
lifting such issues.


More information about the Digitalmars-d mailing list