eval is having 2 arguments, so how to apply it to expression sequences?

eval(x=1,x=2,x=y);
Error, invalid input: 
    eval expects 1 or 2 arguments, but received 3

The usual approach is to convert an expression sequence to a list, apply eval, and then either use op, or [] at the end to convert it back to an expression sentence. Something like

eval([x=1,x=2],x=y)[];

                             y = 1, y = 2

or use quotting,

eval('x=1,x=2',x=y);

                             y = 1, y = 2

I've noticed that rcurry allows doing that without conversion to lists, or quotting,

rcurry(eval,x=y)(x=1,x=2);

                             y = 1, y = 2

In other words, rcurry(f, z)(x,y) is not f(x,y,z), as it is said in the help page, but it is f('x,y',z).

This is unexpected, but useful.

Alec


Please Wait...