Re: Add syntax highlighting to own command
- To: mathgroup at smc.vnet.net
- Subject: [mg101763] Re: Add syntax highlighting to own command
- From: earthnut at web.de (Bastian Erdnuess)
- Date: Thu, 16 Jul 2009 08:20:15 -0400 (EDT)
- References: <200907090600.CAA17547@smc.vnet.net> <h3766u$f9h$1@smc.vnet.net> <h3cfbl$ick$1@smc.vnet.net> <h3kd88$fqv$1@smc.vnet.net>
Bastian Erdnuess <earthnut at web.de> wrote: > Simon <simonjtyler at gmail.com> wrote: > > > An interesting discussion! > > > Ultimately using a Fold construct would be the nicest, but passing > > unevaluated arguments around isn't always so simple > > Indeed. > > Here is another solution using Fold. It's probably not the very best > idea to do it like that, but I want to present it anyway, since it was > not here so far, I guess. > > ClearAll[ take ] > > SetAttributes[ take, HoldAll ] > > take[ list_, expr_ ] := > ToExpression @ > Fold[ > "With[ { " <> #2 <> " }, " <> #1 <> " ]" &, > ToString @ Unevaluated[ expr ], Better to use here ToString[ Unevaluated[ expr ], InputForm ] instead. > Reverse[ > Function[ > lst, > ToString[ Unevaluated[ lst ], InputForm ], > HoldAll > ] /@ Unevaluated[ list ] > ] > ] BTW: No clue, why I called it now "take". Bastian PS: Has somebody a hint how to get lhs := Let[ vars, expr /; cond ] to work?
- References:
- Add syntax highlighting to own command
- From: earthnut@web.de (Bastian Erdnuess)
- Add syntax highlighting to own command