Nested list element at position specified by a list

I’m trying to avoid constructions like Y[[X[[1]], X[[2]], X[[3]]]].

That is we have a nested list (Y) of depth nn and another list of depth 1 and length nn (X). We want to access the element of Y whose indexes coordinates are exactly the elements of X. What is the most reasonable way here?




Does Extract[y,x] work?
– Algohi
Dec 24 ’14 at 0:24



Wow, apparently it does, thanks a lot!
– Igor Makhlin
Dec 24 ’14 at 0:44


1 Answer


As mentioned in the comment, you can try:



y[[Sequence @@ x]]



Yep, both of them work!
– Igor Makhlin
Dec 24 ’14 at 0:50



also y[[##]] & @@ x
– Mr.Wizard♦
Dec 24 ’14 at 7:37