This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Sow

Sow[e]
specifies that e should be collected by the nearest enclosing Reap.
Sow
specifies that e should be collected by the nearest enclosing Reap whose pattern matches tag.
Sow
specifies that e should be collected once for each pattern that matches a .
  • Sow returns e.
  • By having several identical , a single expression can be made to appear multiple times in a list returned by Reap.
  • Sow sows an expression with tag {tag}.
Evaluate a sequence of expressions, "sowing" some to be collected by Reap:
Compute a sum, "sowing" at each step:
Make separate lists for expressions "sown" with different tags:
Reap only expressions "sown" with tag :
Evaluate a sequence of expressions, "sowing" some to be collected by Reap:
In[1]:=
Click for copyable input
Out[1]=
 
Compute a sum, "sowing" at each step:
In[1]:=
Click for copyable input
Out[1]=
 
Make separate lists for expressions "sown" with different tags:
In[1]:=
Click for copyable input
Out[1]=
 
Reap only expressions "sown" with tag :
In[1]:=
Click for copyable input
Out[1]=
Sow can be used anywhere in a computation:
It still works inside a function:
A single expression can be "sown" with multiple tags:
If a single tag is repeated, the expression is sown repeatedly:
A pattern in Reap can be used to specify which tags to collect:
The default is the pattern , so that everything is collected:
Tags can have any form; here they are True and False:
Make a list of all the steps taken in evaluating FindRoot:
Evaluate an iterated map, keeping iterates that are below 1/100:
Find equivalence classes with respect to the value of mod 10:
Sow[x] returns x, "sowing" it as a side effect:
Expressions sown are reaped by the innermost enclosing Reap:
New in 5