Re: [Q] Thread[] and Hold[]
- To: mathgroup at smc.vnet.net
- Subject: [mg18820] Re: [Q] Thread[] and Hold[]
- From: "Alex Scheitlin" <alex-s at worldnet.att.net>
- Date: Thu, 22 Jul 1999 08:19:34 -0400
- Organization: AT&T WorldNet Services
- References: <7n142g$bft@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thread without the second argument threads over lists. With the second argument it threads over expressions with head second argument. Documentation says: Thread[f[args], h] threads f over any objects with head h that appear in args. Thus Thread[f[h[a],h[b],h[c]] returns h[f[a, b, c]]. In your case f is List and h is Hold. Kevin Jaffe <kj0 at mailcity.com> wrote in message news:7n142g$bft at smc.vnet.net... > to comp.soft-sys.math.mathematica, I learned a neat, but rather > puzzling, trick: > > In[4]:= Thread[Hold[{a,b,c}]] (* This I understand *) > > Out[4]= {Hold[a], Hold[b], Hold[c]} > > In[5]:= Thread[%, Hold] (* This baffles me *) > > Out[5]= Hold[{a, b, c}] > > > I can't explain why the form in [5] would be the inverse of the form > in [4], but be that as it may, with this maneuver one can do nifty > things like: > > In[16]:= Thread[{Hold[1 + 1], Hold[3^2], Hold[3*6]}, Hold] > > 2 > Out[16]= Hold[{1 + 1, 3 , 3 6}] > > Neither under Thread nor Hold could I find any explanation in the > Mathematica Book for the behavior in [5]. Does anybody know an > explanation for it? > > Thanks, > > KJ > > > > Get your FREE Email at http://mailcity.lycos.com > Get your PERSONALIZED START PAGE at http://my.lycos.com > . >