Apl2ToDoSelectingPositionsAlgorithms
This is a sub-page of PhraseBook/ToDo/Apl2Idioms
P←(⊂[1]CM)⍳¨' ' ⍝ Position of first blanks in rows of M.
P←(⊂[2]CM)⍳¨' ' ⍝ Position of first blanks in rows of M.
P←(CM≠' ')⌈.×⍳¯1↑⍴CM ⍝ Position of trailing blanks in rows
P←(⊂[1]MY)⍳⊂[1]MX ⍝ Row positions of MX in MY.
P←(⊂[2]MY)⍳⊂[2]MX ⍝ Row positions of MX in MY.
P←(<\MX^.=⍉MY)+.×⍳↑⍴MY ⍝ Row positions of MX in MY (0 for not found).
P←B/⍳⍴B ⍝ Positions of ones in boolean vector B.
P←(+/B)↑⍒B ⍝ Positions of ones in boolean vector B.
P←B/⍳↑⍴A ⍝ Row positions given boolean vector B.
VP←(,BA)/,↑∘.,/⍳¨⍴BA ⍝ Vector of positions of ones in boolean array.
PM←⍉(⍴A)⊤P ⍝ Coordinates of A corresponding to offsets P.
PM←1+⍉(⍴A)⊤P-1 ⍝ Coordinates of A corresponting to offsets P.
P←¯1↓+\0,L ⍝ Positions of ones given length vector L.
P←¯1↓+\1,L ⍝ Positions of ones given length vector L.
P←(<\~CMε' ')+.×⍳¯1↑⍴CM ⍝ Position of the first non-blank char by row.
P←(↑⌽⍴CM)-(1,CM=' ')⊥1 ⍝ Position of the last non-blank char by row.
P←1+(↑⌽⍴CM)-(1,CM=' ')⊥1 ⍝ Position of the last non-blank char by row.
PO←(C≠' ')⍳1 ⍝ Position of the first non-blank char.
PO←(⍴C)-(1,C=' ')⊥1 ⍝ Position of the last non-blank char.
PO←1+(⍴C)-(1,C=' ')⊥1 ⍝ Position of the last non-blank char.
PO←B⍳1 ⍝ Position of the first satisfied condition.
PO←(+\X≡¨Y)⍳NS ⍝ Position of the NSth Y in X.
PO←VV⍳⊂C ⍝ Position of first occurrence of C in VV.
PO←(⌽X)⍳Y ⍝ Position of last Y in X - from left.
PO←(⍴X)-(1,X≠Y)⊥1 ⍝ Position of last Y in X.
PO←1+(⍴X)-(1,X≠Y)⊥1 ⍝ Position of last Y in X.
P←(C⍷CX)/⍳⍴CX ⍝ Positions of start of C in string CX.
P←(CXεC)/⍳⍴CX ⍝ Positions of items in set C in string CX.
P←↑(~CXεC)/⍳⍴CX ⍝ Position of first item in CX not in C.
APL Wiki