Re: Part
- To: mathgroup at smc.vnet.net
- Subject: [mg2926] Re: [mg2890] Part
- From: groskyd at gv.ssi1.com (David Rosky)
- Date: Thu, 11 Jan 1996 01:11:55 -0500
- Organization: Silicon Systems, Inc.
In <4cqk8l$j4c at dragonfly.wri.com>, brucec at wri.com (Bruce Carpenter) writes:
>
>Here is another way to solve your problem. A top-level mechanism has been
>provided to specify a sequence of variables:
>
>In[9]:=
>
>w={{1,2,3},{4,5,6},{7,8,9}};
>npos={2,1};
>
>In[11]:=
>w[[##]]& @@ npos
>
>Out[11]=
>4
>
>In a pure function, # specifies the first variable, #n specifies the nth
>variable, ## the sequence of all variables, and ##n the sequence of
>variables starting with the nth one.
>
It's interesting to note that if just apply the function ## to npos:
In[1] := npos = {2,1};
In[2] := ## & @@ npos
You get:
Out[1] := Sequence[2, 1]
Even though Sequence is not documented in the book, it is documented
on-line as a form:
In[2]:= ?Sequence
Sequence[e1,e2,...] is a special form representing a sequence of arguments in
an expression.
It appears that Sequence is the "head" which is internally given to any list of
elements which doesn't have an explicit head. Maybe it is an internal form
normally used to keep track of lists of arguments to functions and the like.
--David
----------------- groskyd at gv.ssi1.com --------------------
==== [MESSAGE SEPARATOR] ====