MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Add syntax highlighting to own command

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101706] Re: Add syntax highlighting to own command
  • From: earthnut at web.de (Bastian Erdnuess)
  • Date: Wed, 15 Jul 2009 07:07:02 -0400 (EDT)
  • References: <200907090600.CAA17547@smc.vnet.net> <h3766u$f9h$1@smc.vnet.net> <h3cfbl$ick$1@smc.vnet.net>

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 ], 
      Reverse[
        Function[
          lst, 
          ToString[ Unevaluated[ lst ], InputForm ],
          HoldAll
        ] /@ Unevaluated[ list ]
      ]
    ]

Bastian


  • Prev by Date: [bug] exporting GraphicsRow of ListLogLogPlot does not work when
  • Next by Date: Re: Manipulate[] eval hold until all controls are changed?
  • Previous by thread: Re: Add syntax highlighting to own command
  • Next by thread: Re: Add syntax highlighting to own command