Re: Lisp-like let in Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg63461] Re: Lisp-like let in Mathematica?
- From: "Richard Fateman" <fateman at cs.berkeley.edu>
- Date: Sun, 1 Jan 2006 01:16:15 -0500 (EST)
- References: <dp5rpt$rpm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
You might read about Block or Module. Or perhaps if you prefer let* in common lisp.. BlockX[{}, E_] := E BlockX[{a_, b___}, E_] := Block[{a}, BlockX[{b}, E]] Attributes[BlockX] = {HoldAll} As for whether your program is "good" Mathematica style, it seems to me that it is a matter of taste. Some people would say yes. I agree with you that it looks backwards, and by using so many operators it raises questions about precedence between them. Does Mathematica do the right thing? RJF ----- Original Message ----- From: <theran at gmail.com> To: mathgroup at smc.vnet.net Subject: [mg63461] Lisp-like let in Mathematica? > Are functions like > > RealizeGraphicMatroid[G_] := > IncidenceMatrix[#] - IncidenceMatrix[ReverseEdges[#]] & @ > OrientGraph[G] // Transpose > > considered to be good Mathematica style? This does what I want, but it > has the problem of being written in a right-to-left-to-right style. Is > there an operator that works like let in Lisp that can give a local > name to a temporary value in an easier to read way? I guess something > like > > Let[a_ , b_, body_] := > (body /. a -> #) & @ b > > would work, but I'm relatively new to Mathematica and was wondering if > there is a built-in or less clunky solution. > > ^L >