Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question about concatenation “a||b” in Maple?

1 view
Skip to first unread message

Rex

unread,
Feb 8, 2012, 5:54:57 AM2/8/12
to
I test the code

L=[2,1];
sum('a||b*L[1]', 'b' = 1 .. 2);

It returns `a1*L[1]+a2*L[1]`, but I expect to get `a1*2+a2*2` after
evaluation of `L[1]`.
Any ideas?

Rex

unread,
Feb 8, 2012, 5:53:51 AM2/8/12
to

A. van der Meer

unread,
Feb 8, 2012, 10:22:50 AM2/8/12
to
(1) Change L=[2,1]; into L := [ 2,1];
(2) add(a||b*L[1], b = 1 .. 2);

Adri

Rex

unread,
Feb 8, 2012, 1:57:16 PM2/8/12
to
Great thanks Adri. Sorry for my typo for "L:=".

I have one further question. Here's the test code:

L := [2, 1]
test := proc (i) local a1; a1 := 1; add(a || b*L[i], b = 1 ..
2) end proc
test(1);
will result
2 a1 + 2 a2
without evaluating `a1` which is a local variable defined in function
test.
I expect to get `2*1+2*a2`.



On Feb 8, 7:22 am, "A. van der Meer"

Joe Riel

unread,
Feb 8, 2012, 3:52:26 PM2/8/12
to
Rex <aoi...@gmail.com> writes:

> Great thanks Adri. Sorry for my typo for "L:=".
>
> I have one further question. Here's the test code:
>
> L := [2, 1]
> test := proc (i) local a1; a1 := 1; add(a || b*L[i], b = 1 ..
> 2) end proc
> test(1);
> will result
> 2 a1 + 2 a2
> without evaluating `a1` which is a local variable defined in function
> test.
> I expect to get `2*1+2*a2`.

The catenation operator generates global variables, not locals.
Using indexing if you want to refer to a local by an index.

--
Joe Riel

Rex

unread,
Feb 8, 2012, 5:34:34 PM2/8/12
to
Got it. Thank you very much, Joe.

Have a nice day.
0 new messages