Re: Using Hold, ReleaseHold, and Unevaluated
- To: mathgroup at smc.vnet.net
- Subject: [mg2340] Re: Using Hold, ReleaseHold, and Unevaluated
- From: wagner at goober.cs.colorado.edu (Dave Wagner)
- Date: Wed, 25 Oct 1995 02:13:03 -0400
- Organization: University of Colorado, Boulder
In article <DGxuxt.GIJ at wri.com>, I wrote:
>this function flattens a nested list without allowing the
>stuff inside of it to evaluate...
>...I defined my own "hold" head hh so that
>there'd be no confusion in case the expression being flattened
>contained, e.g., literal calls to Hold.
>
> In[2]:=
> SetAttributes[hh, HoldAll]
> SetAttributes[flat, HoldFirst]
> flat[stuff_] :=
> Flatten[Hold[stuff] /. List->Hold, Infinity, Hold] /.
> Hold[x__] :> Hold[{x}]
> In[5]:=
> flat[{{x1, x2}, {{x3}, x4}}]
> Out[5]=
> Hold[{x1, x2, x3, x4}]
As you can see, I never use the head "hh". Originally I wrote the
function like this:
Flatten[hh[stuff] /. List->hh, Infinity, hh]
but upon reflection decided to use Hold instead of hh. Unfortunately,
I didn't change the explanation of the function to match. Sorry
for any confusion this might have caused.
Dave Wagner
Principia Consulting
(303) 786-8371
dbwagner at princon.com
http://www.princon.com/princon