Re: on passing arguments to a function, how to break a list into separate items during a call?

• To: mathgroup at smc.vnet.net
• Subject: [mg103727] Re: on passing arguments to a function, how to break a list into separate items during a call?
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Sun, 4 Oct 2009 05:34:41 -0400 (EDT)

```On 10/3/09 at 9:01 AM, nma at 12000.org (Nasser Abbasi) wrote:

>Suppose there is a function foo[] which returns back 2 items, say
>'i' and 'j'. They must be returned as a list ofcourse, so we have
>this

>foo[] := Module[{i, j},
>i = 3; j = 7; {i, j}
>]

>Now I have another function goo[] which accepts 2 items as input,
>and does something with them, as in

>goo[i_, j_] := Module[{},
>i + j
>]

>Now I'd like to call foo[], and take its output, and pass it to
>directly to goo[], but I can NOT do the following:

>goo[foo[]]

But you can go goo@@foo[]

In[1]:= foo[] := Module[{i, j}, i = 3;
j = 7;
{i, j}]

In[2]:= goo[i_, j_] := Module[{}, i + j]

In[3]:= goo @@ foo[]

Out[3]= 10

Look up Apply in the documentation

```

• Prev by Date: Re: ListShadowPlot3D
• Next by Date: Help Creating 3D List Line Plot
• Previous by thread: Re: on passing arguments to a function, how to break a
• Next by thread: trouble with entropy scaled calculation of infinite sums