Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

Re: List arguments to functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45566] Re: List arguments to functions
  • From: "Peltio" <peltio at twilight.zone>
  • Date: Wed, 14 Jan 2004 01:26:18 -0500 (EST)
  • References: <bu0cnm$aib$1@smc.vnet.net>
  • Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
  • Sender: owner-wri-mathgroup at wolfram.com

"Chris Rozell" wrote

    myfunc[x_, y_] = Apply[Plus, x + y];
    myfunc[{1, 2, 3}, {4, 5, 6}]

        {5, 7, 9}

>When what I would really like is the number 21

I guess your problem resides in the immediate assignement, and not in the
Flat attribute of Plus. Try using

    myfunc[x_, y_] := Apply[Plus, x + y]

So that you have the whole 'procedure' Apply[Plus... etc] associated to
myfunc, and not the result of its immediate evaluation, i.e., x+y.

Cheers,
Peltio
--
Invalid address in reply-to. Crafty demunging required to mail me.




  • Prev by Date: Wolfram Functions Site
  • Next by Date: typesetting fractions
  • Previous by thread: Re: List arguments to functions
  • Next by thread: Re: List arguments to functions