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

Reap

Reap[expr]
gives the value of expr together with all expressions to which Sow has been applied during its evaluation. Expressions sown using Sow[e] or Sow with different tags are given in different lists.
Reap
reaps only expressions sown with tags that match patt.
Reap
puts expressions associated with each of the in a separate list.
Reap
returns .
  • Sow and Reap provide a convenient way to accumulate a list of intermediate results in a computation.
  • Reap accumulates expressions in the order in which Sow is applied to them.
  • Expressions sown with a particular tag are collected by the innermost Reap whose pattern matches the tag.
Evaluate a sequence of expressions, "reaping" ones that have been "sown":
Compute a sum, "reaping" "sown" at each step:
Evaluate a sequence of expressions, "reaping" ones that have been "sown":
In[1]:=
Click for copyable input
Out[1]=
 
Compute a sum, "reaping" "sown" at each step:
In[1]:=
Click for copyable input
Out[1]=
Make a separate sublist for each tag being reaped:
Count the number of instances of each integer separating the negative:
Apply to each distinct tag and list of values:
Find the unique elements in a list, in the order they first occur (unsorted union):
Find the list of values sampled by Plot:
Remove duplicates from a list, keeping original order:
This is like Union without the sorting:
If no expressions are sown, Reap returns an empty list of expressions it has reaped:
Reap collects expressions in exactly the order they are sown:
The list associated with the first tag to be encountered is given first:
New in 5