Skip to content

Instantly share code, notes, and snippets.

View teake's full-sized avatar

Teake Nutma teake

  • Groningen, The Netherlands
View GitHub Profile
@teake
teake / gist:d914c07f18e89094efa1
Created November 7, 2014 19:03
Mathematica Let scoping construct
ClearAll[Let, let, symbolOrListQ];
SetAttributes[{Let, let, symbolOrListQ}, HoldAll];
Let::lvset = "Local variable specification `1` is not valid.";
Let /: Verbatim[SetDelayed][lhs_, rhs : HoldPattern[Let[__, _]]] :=
Block[{With}, Attributes[With] = {HoldAll};
lhs := Evaluate[rhs /. HoldPattern[With[{}, b_]] :> b]];
Let[args : HoldPattern[Set[_?symbolOrListQ, _] ...], body_] :=