"Jaime E. Villate" <villate at fe.up.pt> schrieb:
> On Mon, 2007-04-16 at 18:43 +0000, Wolfgang Lindner wrote:
> > My students will (fequently) have to calculate function values,
> > function tables etc.
> > So - as far as I know - I should have to write
> >
> > (%i4) subst(x=4, f) /* instead of f(4) */
> >
> > if f is an term. Or is there an better possibility?
> > If there would be an 'term evaluator' like
> >
> > (%i4') f | x=4 /* term f evaluated for x =4 */
> >
> > one would have a simpler and shorter 'functionlike' notation.
>
> you can simply use:
> (%i4'') f, x=4;
> my students get used very quickly to that notation as a synonym for
> f(x=4).
well, Jaime, I was both surprised and convinced :)
In seeking for the logic behind your use of the comma (,) I played a litte bit:
(%i38) f,x=2;
(%o38) 16
(%i39) 2,3;
Improper argument to ev:3 -- an error.
(%i40) 2,x=3;
(%o40) 2
Line (i39) gives the hint in the error message.
So, studying the help for ev() one can see:
"?4.2 Function: ev (expr, arg_1, ..., arg_n) [..]
Evaluates the expression expr in the environment specified by the arguments arg_1, ...,
arg_n.
[..] An alternate top level syntax has been provided for ev, whereby one may just type in
its arguments, without the ev(). That is, one may write simply
---------------------------
expr, arg_1, ..., arg_n
--------------------------- "
By the way, (i40) shows in contrast with (i39) that 2 ist interpreted as a constant
function :)) Charming.
--
HTH Wolfgang