apply(+,...), reduce, sum, ...



On Thursday 15 May 2008 17:05:53 Joachim De Beule wrote:
> Hi All,
>
> I have a number of related questions that keep popping up, probably because
> I am still new to maxima and am missing something still.
>
> For example, how do convert a list to a sum,
> like from [a,b,c] to a+b+c?

Ok, I found it, with lsum. but still, I would like to have something like 
reduce or a way to `apply' an infix operator like + to a list. Is this 
possible?

j.

  
>
> My thoughts and troubles on that so far:
>
> * apply(+,[a,b,c]) does not work because (unlike in lisp) + is an infix
>   operator requiring exactly two arguments.
> * But I don't know of a reduce(+,[a,b,c]) that would do the trick as in
> lisp. Is there something like that available?
> * and I dont want to do something uggly like either
>
>    lambda([l],sum(l[i],i,1,length(l)))([a,b,c])
>
>    or
>
>    block(res:1,
>             for e in [a,b,c] do res: res+e,
>             res)
>
>    Mainly because sometimes maxima doesn't seem to expand such a sum
>    expression them. Can I force maxima to do that?
>
> * I would be happy to do it in lisp but then without having to bother about
> type conversions to much, and I don't know how to do that. Or is this not a
> good idea?
>
> Thanks, Joachim.
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima