Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone help explain it to me:

  1. How does here e come out? Why b disappears?

    Reap[Sow[a]; b; Sow[c]; Sow[d]; e]

enter image description here

  1. How does here 4 come out?

    Reap[Sow[1, x]; Sow[2, y]; Sow[3, x]; Sow[4, y], x]

enter image description here

Thanks a lot!

share|improve this question
up vote 1 down vote accepted

When you have a CompoundExpression the last expression is the result.

Mathematica graphics

Look at the FullForm of the expression inside Reap:

FullForm[HoldForm[Sow[a]; b; Sow[c]; Sow[d]; e]]

Mathematica graphics

In this case, the OutPut is just e, the last one. Now when you include the Reaping, you get things that are Sown in addition to e. Same explanation goes for the second one.

share|improve this answer
Thanks a lot! I will look it up for CompoundExpression. – Lawerance Jul 29 '14 at 7:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.