Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10511 > unrolled thread
| Started by | "Mat' G\." <ellocomateo@free.fr> |
|---|---|
| First post | 2012-06-17 20:47 +0000 |
| Last post | 2012-06-18 09:44 +0000 |
| Articles | 8 — 7 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Parenthesis reduction "Mat' G\." <ellocomateo@free.fr> - 2012-06-17 20:47 +0000
Re: Parenthesis reduction awnl <awnl@gmx-topmail.de> - 2012-06-18 09:46 +0000
Re: Parenthesis reduction Yves Klett <yves.klett@googlemail.com> - 2012-06-18 09:48 +0000
Re: Parenthesis reduction "Nasser M. Abbasi" <nma@12000.org> - 2012-06-19 07:14 +0000
Re: Parenthesis reduction John Doty <noqsiaerospace@gmail.com> - 2012-06-20 07:52 +0000
Re: Parenthesis reduction David Bailey <dave@removedbailey.co.uk> - 2012-06-18 09:49 +0000
Re: Parenthesis reduction David Reiss <dbreiss@gmail.com> - 2012-06-18 09:43 +0000
Re: Parenthesis reduction "Nasser M. Abbasi" <nma@12000.org> - 2012-06-18 09:44 +0000
| From | "Mat' G\." <ellocomateo@free.fr> |
|---|---|
| Date | 2012-06-17 20:47 +0000 |
| Subject | Parenthesis reduction |
| Message-ID | <jrlfoa$c2s$1@smc.vnet.net> |
Which command should one use to get
{a, b, c}, {d, e, f}, {g, h, i}
from
{{a, b, c}, {d, e, f}, {g, h, i}}
?
[toc] | [next] | [standalone]
| From | awnl <awnl@gmx-topmail.de> |
|---|---|
| Date | 2012-06-18 09:46 +0000 |
| Message-ID | <jrmtdo$h4q$1@smc.vnet.net> |
| In reply to | #10511 |
Hi,
> Which command should one use to get
> {a, b, c}, {d, e, f}, {g, h, i}
stricktly speaking this is not a valid mathematica expression, so it
can't be done. But...
> from
> {{a, b, c}, {d, e, f}, {g, h, i}}
> ?
... you most probably want Sequence, which will create something that
you can pass to a function:
arglist = {{a, b, c}, {d, e, f}, {g, h, i}}
argseq = Sequence@@arglist;
f[argseq]
of course you can also directly "Apply" (@@ is the shortcut for "Apply")
the function to the list of arguments:
f@@aglist
hth,
albert
[toc] | [prev] | [next] | [standalone]
| From | Yves Klett <yves.klett@googlemail.com> |
|---|---|
| Date | 2012-06-18 09:48 +0000 |
| Message-ID | <jrmthi$h6o$1@smc.vnet.net> |
| In reply to | #10511 |
Try
Sequence@@{{a, b, c}, {d, e, f}, {g, h, i}}
Cheers,
Yves
Am 17.06.2012 22:47, schrieb Mat' G.:
> Which command should one use to get
> {a, b, c}, {d, e, f}, {g, h, i}
> from
> {{a, b, c}, {d, e, f}, {g, h, i}}
> ?
>
[toc] | [prev] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2012-06-19 07:14 +0000 |
| Message-ID | <jrp8sq$q97$1@smc.vnet.net> |
| In reply to | #10522 |
On 6/18/2012 4:48 AM, Yves Klett wrote:
> Try
>
> Sequence@@{{a, b, c}, {d, e, f}, {g, h, i}}
>
> Cheers,
> Yves
>
>
using V 8.04, this does nothing?
In[1]:= Sequence@@{{a,b,c},{d,e,f},{g,h,i}}
Out[1]= Sequence[{a,b,c},{d,e,f},{g,h,i}]
--Nasser
[toc] | [prev] | [next] | [standalone]
| From | John Doty <noqsiaerospace@gmail.com> |
|---|---|
| Date | 2012-06-20 07:52 +0000 |
| Message-ID | <jrrvfv$4sb$1@smc.vnet.net> |
| In reply to | #10545 |
On Tuesday, June 19, 2012 3:14:34 AM UTC-4, Nasser M. Abbasi wrote:
using V 8.04, this does nothing?
>
> In[1]:= Sequence@@{{a,b,c},{d,e,f},{g,h,i}}
> Out[1]= Sequence[{a,b,c},{d,e,f},{g,h,i}]
What did you expect it to do? {a,b,c},{d,e,f},{g,h,i} is not a proper expression: it has no head, so Sequence[] cannot return it. Sequence[] is not really comprehensible as a "function": in effect it edits its caller's argument list!
Try f[Sequence@@{{a,b,c},{d,e,f},{g,h,i}}]
Always remember that fundamentally, Mathematica is *rewriting expressions* according to rules that *often* correspond to procedure or function evaluation, but sometimes are really something else.
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2012-06-18 09:49 +0000 |
| Message-ID | <jrmtih$h75$1@smc.vnet.net> |
| In reply to | #10511 |
On 17/06/2012 21:47, Mat' G. wrote:
> Which command should one use to get
> {a, b, c}, {d, e, f}, {g, h, i}
> from
> {{a, b, c}, {d, e, f}, {g, h, i}}
> ?
>
The problem is that your first expression isn't syntactically valid, so
I presume what you really mean is something like transforming
{{a, b, c}, {d, e, f}, {g, h, i}}
into say
fun[x,y,{a, b, c}, {d, e, f}, {g, h, i},z]
In other words that you want to embed it in something else:
In[1]:= tmp = {{a, b, c}, {d, e, f}, {g, h, i}}
Out[1]= {{a, b, c}, {d, e, f}, {g, h, i}}
In[2]:= fun[x, y, Sequence @@ tmp, z]
Out[2]= fun[x, y, {a, b, c}, {d, e, f}, {g, h, i}, z]
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | David Reiss <dbreiss@gmail.com> |
|---|---|
| Date | 2012-06-18 09:43 +0000 |
| Message-ID | <jrmt8v$h2d$1@smc.vnet.net> |
| In reply to | #10511 |
The expression
{a, b, c}, {d, e, f}, {g, h, i}
is not syntactically correct in Mathematica. However, if you want to make use of these three lists as three separate arguments in a function, then you can use the somewhat specialized function "Sequence" by Apply-ing it to the original list (I.e., replace the Head of the list with Sequence). Assuming that the function that you want to provide three arguments to is called foo, then here is an example:
foo[ Sequence@@{{a, b, c}, {d, e, f}, {g, h, i}}]
gives
foo[{a, b, c}, {d, e, f}, {g, h, i}]
--David
On Sunday, June 17, 2012 4:47:06 PM UTC-4, Mat' G. wrote:
> Which command should one use to get
> {a, b, c}, {d, e, f}, {g, h, i}
> from
> {{a, b, c}, {d, e, f}, {g, h, i}}
> ?
[toc] | [prev] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2012-06-18 09:44 +0000 |
| Message-ID | <jrmt9t$h2u$1@smc.vnet.net> |
| In reply to | #10511 |
On 6/17/2012 3:47 PM, Mat' G. wrote:
> Which command should one use to get
> {a, b, c}, {d, e, f}, {g, h, i}
> from
> {{a, b, c}, {d, e, f}, {g, h, i}}
> ?
>
I am confused by this question. In general, an
expression, is either a list or not a list.
So what is
{a, b, c}, {d, e, f}, {g, h, i}
supposed to be? it is not a list. and it is not not a list
either. So, I do not know what it is.
Unless you asking for a much more basic question such
as using an idex to access an entry in a list?
lis={{a,b,c},{d,e,f},{g,h,i}}
lis[[1]]
lis[[2]]
lis[[3]]
Out[89]= {a,b,c}
Out[90]= {d,e,f}
Out[91]= {g,h,i}
--Nasser
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web