You'll have to include a counter for the item numbers - as it stands
now, you're putting 2^2 into item 2 of Y, 4^2 into item 4 of Y, and
6^2 into item 6 of Y (at least, that's what it did for me & what it
should do). This is because i is not the item number but the item
itself. You could do this:
put 1 into N
Repeat for each item i in X
put i^2 into item N of Y
add 1 to N
end repeat
Regards,
Dave Tremmel
>Hi Everyone,
>
> Can the "for each" form of the repeat structure be used to transform
>one itemized list into another?
>
> For example, if variable X = 2, 4, 6, I'd like to create variable Y
>as the square of the items of X, so that Y = 4, 16, 36.
>
> I tried doing this:
>
> Repeat for each item i in X
> put i^2 into item i of Y
> end repeat
>
> But what I get is a long list of commas (empty items) and a single
>number at the end (36).
>
> Any thoughts on this?
>
> Regards,
>
> Greg
>
>
>
>
>
>
>_________________________________________
>Gregory Lypny
>Associate Professor of Finance
>Concordia University
>
>_________________________________________
>"Take chances, make mistakes!"
> - Ms Frizzle, The Magic School Bus
>
>
>
>Archives: http://www.mail-archive.com/[email protected]/
>Info: http://www.xworlds.com/metacard/mailinglist.htm
>Please send bug reports to <[EMAIL PROTECTED]>, not this list.
--
*********************************
David Tremmel
Assistant Director, Phytotron
Duke University
Phytotron Bldg.
Box 90340
Durham, NC 27708-0340
Phone: (919) 660-7415
FAX: (919) 660-7425
E-mail: [EMAIL PROTECTED]
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.