I want to select elements from an array based on some test. Currently, I am trying to do that with a compression, and I would like to write it as a tacit function. (I'm very new to APL, so feel free to suggest other options.) Below is a minimal (not-)working example.
The third line below shows that I can use the testing function f
on vec
and then do the compression, and the fifth line shows I can apply the identity function to vec
(as expected). So based on my understanding of the train documentation, I should be able to make a fork from f
and ⊢
with /
as the center prong. Below shows that this does not work, and I presume it is because Dyalog is interpreting the sixth and eighth lines as doing an f
-reduce. Is there a way to indicate that I want a compression train and not a reduce? (and/or is there a better way to do this altogether?)
vec ← 10⍴⍳3
f ← {⍵≤2}
(f vec) / vec
1 2 1 2 1 2 1
(f vec) / (⊢ vec)
1 2 1 2 1 2 1
(f/⊢) vec
1
(f(/)⊢) vec
1