4
$\begingroup$

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!

$\endgroup$
4
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks a lot! I will look it up for CompoundExpression. $\endgroup$ – Lawerance Jul 29 '14 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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