Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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 at 7:11

Your Answer

 
discard

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.