Sow

Sow[e]
specifies that e should be collected by the nearest enclosing Reap.

Sow[e,tag]
specifies that e should be collected by the nearest enclosing Reap whose pattern matches tag.

Sow[e,{tag1,tag2,}]
specifies that e should be collected once for each pattern that matches a .

DetailsDetails

  • Sow[e,] returns e.
  • By having several identical , a single expression can be made to appear multiple times in a list returned by Reap.
  • Sow[e] is equivalent to Sow[e,None].
  • Sow[e,{{tag}}] sows an expression with tag {tag}.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

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]=
Introduced in 2003
(5.0)