Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.6K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

AppendTo vs Reap Sow

Posted 10 years ago

I am a little confused with this two functions: AppendTo adds and resets the variable while Reap and Sow have the attribute Hold and do not return unless finished:

t = Flatten[Reap[For[i = 1, i < 40, i++, Drop[t,{3}]; Print[t]; Sow[i]]][[2]]] 

This will print just t 40 times, not iteratively.

How can I construct a list so that it would update variable in a process of creation as some operations needs to be performed on it meanwhile? This is straightforward with AppendTo but not so with Reap or anything else.

Thanks.

POSTED BY: Al Guy
2 Replies
Posted 10 years ago

Not sure NestWhile will work in my case: It generates random number and then sees whether there is a matching pattern in a nested list, if yes then replaces that element with it and does sub algebra of merging sublists, if not the just appends it to the list.

POSTED BY: Al Guy
Posted 10 years ago
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard