Re: Lisp-like let in Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg63454] Re: [mg63443] Lisp-like let in Mathematica?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 1 Jan 2006 01:16:07 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Module might make it easier to read and has local variables Needs["DiscreteMath`Combinatorica`"]; RealizeGraphicMatroid[G_]:= (IncidenceMatrix[#]-IncidenceMatrix[ReverseEdges[#]]&@ OrientGraph[G])//Transpose; RealizeGraphicMatroid2[G_]:=Module[{og=OrientGraph[G]}, Transpose[IncidenceMatrix[og]- IncidenceMatrix[ReverseEdges[og]]]]; og=4; RealizeGraphicMatroid[CompleteGraph[3]]== RealizeGraphicMatroid2[CompleteGraph[3]] True og 4 Bob Hanlon > > From: theran at gmail.com To: mathgroup at smc.vnet.net > Date: 2005/12/31 Sat AM 06:40:46 EST > Subject: [mg63454] [mg63443] 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 > >