Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2141 > unrolled thread
| Started by | Virgil Stokes <vs@it.uu.se> |
|---|---|
| First post | 2011-05-06 11:24 +0000 |
| Last post | 2011-05-07 11:29 +0000 |
| Articles | 8 — 8 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Converting a list to arguments for a function --- How? Virgil Stokes <vs@it.uu.se> - 2011-05-06 11:24 +0000
Re: Converting a list to arguments for a function --- How? Stefan Salanski <wutchamacallit27@gmail.com> - 2011-05-07 11:31 +0000
Re: Converting a list to arguments for a function --- How? Luci Ellis <luci@verbeia.com> - 2011-05-07 11:33 +0000
Re: Converting a list to arguments for a function --- How? Michael Weyrauch <michael.weyrauch@gmx.de> - 2011-05-07 11:34 +0000
Re: Converting a list to arguments for a function --- How? Jingjing Wang <brightapple2008@gmail.com> - 2011-05-07 11:35 +0000
Re: Converting a list to arguments for a function --- How? Peter Breitfeld <phbrf@t-online.de> - 2011-05-07 11:35 +0000
Re: Converting a list to arguments for a function --- How? AES <siegman@stanford.edu> - 2011-05-07 11:29 +0000
Re: Converting a list to arguments for a function --- How? Yves Klett <yves.klett@googlemail.com> - 2011-05-07 11:29 +0000
| From | Virgil Stokes <vs@it.uu.se> |
|---|---|
| Date | 2011-05-06 11:24 +0000 |
| Subject | Converting a list to arguments for a function --- How? |
| Message-ID | <iq0lpe$2q0$1@smc.vnet.net> |
Suppose I have a list,
list = {4,1,1}
and I wish to use it as follows
f[4,1,1]
Is there a simple way (without looping through the elements list) to transfer
the elements of list to the arguments for f?
[toc] | [next] | [standalone]
| From | Stefan Salanski <wutchamacallit27@gmail.com> |
|---|---|
| Date | 2011-05-07 11:31 +0000 |
| Message-ID | <iq3aiq$fet$1@smc.vnet.net> |
| In reply to | #2141 |
On May 6, 7:24 am, Virgil Stokes <v...@it.uu.se> wrote:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
you want to use Apply, or equivalently @@,
Apply[f,list]
f@@list
hope that helps,
-Stefan S
[toc] | [prev] | [next] | [standalone]
| From | Luci Ellis <luci@verbeia.com> |
|---|---|
| Date | 2011-05-07 11:33 +0000 |
| Message-ID | <iq3an5$fil$1@smc.vnet.net> |
| In reply to | #2141 |
On 2011-05-06 21:24:30 +1000, Virgil Stokes said:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
f @@ list
or Apply[f, list]
Hope that helps.
Regards
Luci
[toc] | [prev] | [next] | [standalone]
| From | Michael Weyrauch <michael.weyrauch@gmx.de> |
|---|---|
| Date | 2011-05-07 11:34 +0000 |
| Message-ID | <iq3ao5$fje$1@smc.vnet.net> |
| In reply to | #2141 |
f@@list
Am 6.5.2011 13:24, schrieb Virgil Stokes:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
>
>
>
>
[toc] | [prev] | [next] | [standalone]
| From | Jingjing Wang <brightapple2008@gmail.com> |
|---|---|
| Date | 2011-05-07 11:35 +0000 |
| Message-ID | <iq3apf$fkj$1@smc.vnet.net> |
| In reply to | #2141 |
On May 6, 4:24 am, Virgil Stokes <v...@it.uu.se> wrote:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
f@@list
[toc] | [prev] | [next] | [standalone]
| From | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| Date | 2011-05-07 11:35 +0000 |
| Message-ID | <iq3apq$fks$1@smc.vnet.net> |
| In reply to | #2141 |
Virgil Stokes wrote:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
f[Sequence@@list]
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
[toc] | [prev] | [next] | [standalone]
| From | AES <siegman@stanford.edu> |
|---|---|
| Date | 2011-05-07 11:29 +0000 |
| Message-ID | <iq3af4$fbt$1@smc.vnet.net> |
| In reply to | #2141 |
In article <iq0lpe$2q0$1@smc.vnet.net>, Virgil Stokes <vs@it.uu.se>
wrote:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
I seem to recall that Sequence does this, but don't have time just at
the moment to open Mathematica and check this.
[toc] | [prev] | [next] | [standalone]
| From | Yves Klett <yves.klett@googlemail.com> |
|---|---|
| Date | 2011-05-07 11:29 +0000 |
| Message-ID | <iq3aff$fc5$1@smc.vnet.net> |
| In reply to | #2141 |
Hi,
probably answer no.200 with redundant content on this, but:
look at Apply or @@:
f @@ {4, 1, 1}
f[4, 1, 1]
Regards,
Yves
Am 06.05.2011 13:24, schrieb Virgil Stokes:
> Suppose I have a list,
>
> list = {4,1,1}
>
> and I wish to use it as follows
>
> f[4,1,1]
>
> Is there a simple way (without looping through the elements list) to transfer
> the elements of list to the arguments for f?
>
>
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web