Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple-Indexing nested matrices in APL

Tags:

apl

I've looked everywhere for a function to do this but given a nested vector

A←(5 3 2) (3 9 1)

I'd like to index it with B

B ← 2 1

So that for the first item in A, the 2nd item will be returned. And for the second item for A will have 3 (the first item) returned.

like image 596
Chris Zhang Avatar asked Apr 26 '26 14:04

Chris Zhang


2 Answers

You want the index function, applied with the each operator:

      A←(5 3 2) (3 9 1) 
      B←2 1
      B⌷¨A
3 3

Note that you should not confuse the index function with the quad function, which is a wider box.

like image 83
Paul Mansour Avatar answered May 04 '26 02:05

Paul Mansour


You could also use "pick": B⊃¨A

like image 30
John Stewart Avatar answered May 04 '26 01:05

John Stewart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!