axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-mail] How to make series of variables with indexes?


From: Bill Page
Subject: Re: [Axiom-mail] How to make series of variables with indexes?
Date: Wed, 9 Jul 2008 17:42:02 -0400

2008/7/9 Соловьев Александр Александрович :
>
> Yes, it does help. Thanks a lot. And one more question about subscript(). Why 
> it doesn't work in sum() context? I.e.
>
> sum(subscript(a,[i]), i=0..3)
>
> gives 4ai instead of sum a0 + a1 + a2 ...
>

Arguments of functions are always evaluated before calling the
function. In this case 'subscript(a,[i])' is evaluated first to yield
the name 'a_i' before calling 'sum'.

Instead of 'sum' you can use:

  reduce(+,[subscript(a,[i]) for i in 0..3])

The expression for list comprehension

   [x for y in z]

evaluates x only after substitution.

Regards,
Bill Page.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]