On 1/3/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
> Given a list, say xx: [2,1,3,3,5], how would I use 'sublist' to
> extract the indices where '3' occurs?
I think this is a general problem and Maxima should have a built-in
function for it. How about if we call it "find".
Here's an attempt which worked OK for the one example I tried:
find (L, p) := block ([I : makelist (i, i, 1, length (L))], sublist
(I, lambda ([i], is(p(L[i])))));
xx: [2,1,3,3,5];
P(x) := x=3;
find (xx, P);
=> [3, 4]
find (xx, lambda ([x], x=3));
=> [3, 4]
Of course we would want to rewrite it in Lisp.
All the best,
Robert