Re: Taking brackets off lists
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg291] Re: [mg281] Taking brackets off lists
- From: Xah Y Lee <xyl10060 at fhda.edu>
- Date: Mon, 5 Dec 1994 22:29:51 -0800 (PST)
On Sun, 4 Dec 1994, corcoran wrote: > If I have a list like, > > list = {1,1,1,2} > > how do I find the part of a expression at the level specified by the list? > i.e. > > I want exp[[1,1,1,2]], > > but exp[[list]] doesn't work. > > Thanks, > Stephen > mylist = {1,1,1,2}; expr = Table[Random[Integer,{0,10}],{3},{2},{3},{3}]; expr[[Sequence@@mylist]] or Part[expr, Sequence@@mylist ] will give you what you want. Sequence[] is not documented. In general, f[Sequence[x1,x2,...,xn]] will evaluate to f[x1,x2,...,xn]. Reference: _Programming in Mma_ by Roman Maeder. Also mentioned in _Mma Quick Ref. v2_ by Nancy Blachman. Xah Mountain View, CA temporary email: xyl10060 at tiptoe.fhda.edu permament email: 74631.731 at compuserve.com