Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Variables within With statement
Replies: 5   Last Post: Dec 22, 2011 4:01 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Simon Tyler

Posts: 166
Registered: 8/14/06
Re: Variables within With statement
Posted: Dec 16, 2011 5:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

This has come up a few time recently on this mathgroup and stackoverflow:

https://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/6fa6b0ad9d5d111c
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/3a5ae92bda1c7511
http://stackoverflow.com/a/5692010/421225
http://stackoverflow.com/a/4191096/421225

For what it's worth, here's the various versions I keep floating around

SetAttributes[Let, HoldAll];
SyntaxInformation[Let] = {"ArgumentsPattern" -> {{__}, _}};
Let[{}, expr_] := expr
Let[{a_, b___}, expr_] := With[{a}, Let[{b}, expr]]
SetAttributes[WithRules, HoldRest]
WithRules[rules_, expr_] := With@@Append[Apply[Set, Hold@rules, {2}], Unevaluated[expr]]
SetAttributes[LetRules, HoldRest]
LetRules[rules_, expr_] := Let@@Append[Apply[Set, Hold@rules, {2}], Unevaluated[expr]]

Simon




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.