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[e,tagi] with different tags are given in different lists.


reaps only expressions sown with tags that match patt.


puts expressions associated with each of the patti in a separate list.


returns {expr,{f[tag1,{e11,e12,}],}}.


  • 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.
  • Reap[expr] is equivalent to Reap[expr,_].
  • Reap has attribute HoldFirst.


open allclose all

Basic Examples  (2)

Evaluate a sequence of expressions, "reaping" ones that have been "sown":

Compute a sum, "reaping" i^2 "sown" at each step:

Scope  (2)

Make a separate sublist for each tag being reaped:

Count the number of instances of each integer separating the negative:

Generalizations & Extensions  (1)

Apply f to each distinct tag and list of values:

Applications  (2)

Find the list of values sampled by Plot:

Remove duplicates from a list, keeping original order:

This is like Union without the sorting:

Properties & Relations  (3)

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:

Wolfram Research (2003), Reap, Wolfram Language function,


Wolfram Research (2003), Reap, Wolfram Language function,


@misc{reference.wolfram_2020_reap, author="Wolfram Research", title="{Reap}", year="2003", howpublished="\url{}", note=[Accessed: 16-January-2021 ]}


@online{reference.wolfram_2020_reap, organization={Wolfram Research}, title={Reap}, year={2003}, url={}, note=[Accessed: 16-January-2021 ]}


Wolfram Language. 2003. "Reap." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2003). Reap. Wolfram Language & System Documentation Center. Retrieved from