MathGroup Archive 1999

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

Search the Archive

Re: [Q] Thread[] and Hold[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18802] Re: [mg18785] [Q] Thread[] and Hold[]
  • From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
  • Date: Thu, 22 Jul 1999 08:19:23 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

What you are really doing is evaluating:

Thread[List[Hold[a],Hold[b],Hold[c]},Hold]

Mathematica gives you full explanation of this usage:


Thread[f[args],  h] threads f over any objects with head h that appear in
args.

In other words you are threading List over all arguments with head Hold. So
naturally you get

Hold[List[a,b,c}]

--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp


----------
>From: "Kevin Jaffe" <kj0 at mailcity.com>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg18802] [mg18785] [Q] Thread[] and Hold[]
>Date: Tue, Jul 20, 1999, 6:33 AM
>

> 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


  • Prev by Date: Exporting PRINT results from Mathematica to other applications
  • Next by Date: Re: How NDSolve counts Conditions
  • Previous by thread: [Q] Thread[] and Hold[]
  • Next by thread: Re: [Q] Thread[] and Hold[]