Search code examples
indexingmulti-indexapldyalogtacit-programming

How can I extract multiple elements from a matrix in an APL tacit function?


(Dyalog) APL learner question

If I have a matrix Y:

          Y
4 9 2
3 5 7
8 1 6

I can get two of its members like this:

      Y[(1 1) (2 2)]
4 5

I can use the same technique using dfn syntax:

      {⍵[(1 1) (2 2)]}Y
4 5

I, however, can't work out how to do the equivalent in a tacit function. In particular it seems that bracket indexing doesn't work in a tacit function, and I can't find a way of using squad indexing with list of indexes.

Is there a way of doing this, or is this a limitation of tacit functions?

Note that in my real example the list of indexes is generated, so I can't simply do (((1 1)⌷⊢),(2 2)⌷⊢)Y or anything similar.


Solution

  • (1 1)(2 2)⌷¨⊂Y
    

    works, also

    (1 1)(2 2)⊃⍤0 99⊢Y