I am sure Rascal has built in support for Stack (e.g. for expression eval via stack push/pop), but I cannot find anything.
So I now use this. However is there a nicer way?
list stack = [];
pop:
value = stack[size(stack)-1];
stack = stack - value;
push
stack = stack + value
I'd recommend changing pop to:
value = stack[-1]; //short hand notation
stack = delete(stack, size(stack)-1); // to make sure the last item is deleted (in case duplicates exist in the list)