Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 2
    $\begingroup$ We could achieve the same effect using Block[{data = Range[5], len := Length[data]}, {len, data}]. But a more conventional solution would be to avoid the deferred execution using the somewhat repetitive but idiomatic Block[{data, len}, data = Range[5]; len = Length[data]; {len, data}]. Incidentally, Block is the analog to Scheme's fluid-let so the sequencing issue is not as likely to arise for Block as it would if instead we were using Module (= Scheme's let). $\endgroup$ Commented Dec 21, 2019 at 20:28
  • $\begingroup$ As I said in a comment to Carl's answer above, I completely missed the fact we can use delayed affectation :/ Anyhow, thanks for the comment @WR, and for mentioning the "idiomatic" way of solving the issue! $\endgroup$ Commented Dec 21, 2019 at 23:03