Postfix notation in MAPLE

162 Views Asked by At

I usually use MATHEMATICA as a computer algebra system and there I heavily employ the postfix notation (achieved by "//" at the end of some command), e.g.

Table[{x, Sin[x]}, {x, 0, 3, 0.1}] // ListPlot[#, PlotRange -> {0, 1}] &

Now I'm wondering whether or not something like this exists in MAPLE as well. Maybe someone with a bit of experience in both CAS's is able to translate the simple example above to MAPLE. Thank you very much in advance!

1

There are 1 best solutions below

2
On BEST ANSWER

Normally in Maple you would wrap the trailing command around the former, and also perhaps use the special % name. Eg,

restart:
with(plots):

listplot( [seq(sin(x), x=0..1, 0.1)], color=blue, view=0..2 );

or,

[seq(sin(x), x=0..1, 0.1)], color=blue:
listplot( %, view=0..2 );

If you really want to you can mimic what you've called the "postfix" syntax (which looks like infix, IMO, but no matter the name). This is somewhat similar (and you can adjust how it works, or make it fancier, etc).

restart:

`&//` := proc(A::list,B::{list,appliable})
           if type(B,list) then
             return B[1](A[], B[2..-1][]);
           else
             return B(A[]);
           end if;
         end proc:

with(plots):

[ [seq(sin(x), x=0..1, 0.1)], color=blue ] &// [ listplot, view=0..2 ];

[ [seq(sin(x), x=0..1, 0.1)] ] &// listplot;

[ plot(sin(x),x=-Pi..Pi) ] &// [ plottools:-rotate, -Pi/2 ];

[ nextprime(1000)+1 ] &// ifactor;