tellsimp: can a pattern match the "rest" of a list?



On 3/28/2011 8:19 AM, Henry Baker wrote:
> I tried
>
> matchdeclare([a,b],true);
> tellsimp(cons(a,b),foo(a,b));
>
> [1,2,3];
>
> I wanted to get foo(1,[2,3]), but still got [1,2,3].
>
> Is there any way to achieve this?
>
> [It probably isn't critical to my application, but was merely curious.]
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
Consider this ....

k(a,b,c,d),    k =lambda([[a]], if a=[] then nil else 
foo(first(a),apply(k,rest(a))));

this produces

foo(a,foo(b,foo(c,foo(d,nil))))