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

nested seq

0 views
Skip to first unread message

moro

unread,
Nov 9, 2009, 9:55:08 AM11/9/09
to
I would like to do a nested sequence (or for loop) but the number of
iterations is not necessarily fixed:

I tried doing the following:

nestedseq:=proc(numtimes,middle)
return cat(seq(`seq(`,i=1..numtimes),middle,seq(`,j[i]=[1,2,3])
`,i=1..numtimes));
end proc;

But then I get a string with the desired command but I cannot evaluate
it. Is there a better way to do these iterated sequences?

Thanks a lot,

Roman Pearce

unread,
Nov 9, 2009, 10:48:33 PM11/9/09
to
On Nov 9, 6:55 am, moro <ahmora...@gmail.com> wrote:
> nestedseq:=proc(numtimes,middle)
>  return cat(seq(`seq(`,i=1..numtimes),middle,seq(`,j[i]=[1,2,3])
> `,i=1..numtimes));
> end proc;

I think the problem here is that "middle" is messing up the syntax of
the outermost seq. Try the following:

seq(op([seq(something, i=1..numtimes), middle, seq(something_else, j=
[1,2,3])]), k=1..numtimes);

0 new messages