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

That is we have a nested list (Y) of depth $n$ and another list of depth 1 and length $n$ (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?

  • 2
    $\begingroup$ Does Extract[y,x] work? $\endgroup$ Dec 24, 2014 at 0:24
  • $\begingroup$ Wow, apparently it does, thanks a lot! $\endgroup$
    – imakhlin
    Dec 24, 2014 at 0:44

1 Answer 1


As mentioned in the comment, you can try:



y[[Sequence @@ x]]
  • $\begingroup$ Yep, both of them work! $\endgroup$
    – imakhlin
    Dec 24, 2014 at 0:50
  • $\begingroup$ also y[[##]] & @@ x $\endgroup$
    – Mr.Wizard
    Dec 24, 2014 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.