Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Q: Thread behaviour

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57969] Re: Q: Thread behaviour
  • From: dh <dh at metrohm.ch>
  • Date: Tue, 14 Jun 2005 05:10:36 -0400 (EDT)
  • References: <d8jlgk$stn$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Dick,
if a function does not have the attribute "HoldAll" or "HoldFirst", the 
arguments are evaluated before beeing fed to the function. Therefore, 
k[a+b,c d] is evaluated according to the definition you gave: k[x_,y_] = 
x^2+y^2, resulting in:
(a+b)^2 + (c d)^2
and this is fed to Thread (Note that k disappeared!).
sincerely, Daniel

Dick Barends wrote:
> Hallo,
> 
> k[x_,y_] = x^2+y^2
> Thread[k[a+b,c d],Plus]
> gives: (a+b)^2+c^2 d^2
> I would expect: a^2 + (c d)^2 + b^2 + (c d)^2 (See below)
> 
> -----------------
> When I use:
> Thread[m[a+b, c d],Plus]
> gives: m[a, c d] + m[b, c d]
> This is what should happen.
> 
> What gives "m" a different solution than "k"????
> 
> I hoop some of you will answer:-)
> 
> greetings
> Dick
> 


  • Prev by Date: Re: Thread behaviour
  • Next by Date: Re: Applying function to nested lists
  • Previous by thread: Re: Q: Thread behaviour
  • Next by thread: Re: Q: Thread behaviour