arrow for lambda forms (was Re: posible bug - clashing variable names in integrals)



(%i7) if not member(lambda, map('op, macros)) then (
infix("->",50,50),
"->"(x,f) ::= (x : if listp(x) then x else [x], buildq([x,f], lambda
(x,f))))$

One variable:

 (%i8) f : [x] -> x^2;
 (%o8) lambda([x],x^2)

 (%i9) f(5);
 (%o9) 25

Also one variable:

 (%i10) g : x -> x^2;
 (%o10) lambda([x],x^2)

 (%i11) g(5);
 (%o11) 25

Two variable:

 (%i12) h : [x,y] -> x + y;
 (%o12) lambda([x,y],y+x)

 (%i13) h(5,7);
 (%o13) 12

n-variables:

 (%i15) s : [[x]] -> xreduce("+",x);
 (%o15) lambda([[x]],xreduce(+,x))

 (%i16) s(a,b,c);
 (%o16) c+b+a

Useful? Buggy?

Barton

-----macrakis at gmail.com wrote: -----

>To:?Barton?Willis?<willisb at unk.edu>
>From:?Stavros?Macrakis?<macrakis at alum.mit.edu>
>Sent?by:?macrakis at gmail.com
>Date:?10/04/2009?11:56AM
>cc:?maxima?<maxima at math.utexas.edu>
>Subject:?Re:?[Maxima]?posible?bug?-?clashing?variable?names?in?integrals
>
>
>
>On?Sun,?Oct?4,?2009?at?12:36?PM,?Barton?Willis?<willisb at unk.edu>?wrote:
>
>...I?used?"->"?as?shorthand?for?a?lambda?form:
>
>?(%i4)?fsum(k?->?1/k,1,n);
>
>?(%o4)?psi[0](n+1)+%gamma
>
>I?like?the?idea?of?a?concise?syntax?for?lambda-expressions,?but?how?to
>generalize?to?more?than?one?argument??Perhaps?[x,y]->x/y?or?(x,y)->x/y?or
>something?
>
>
>??????????-s