I have created a dyadic verb which expects a number and a vector and returns the vector filtered to contain those which divide the number, like this:
divs =. 4 : '((=<.)y%x)#y'
So, for example, 4 divs i.20
returns 0 4 8 12 16
as expected.
Now I'd like to modify/wrap this verb so that the first argument can be a vector as well, and return either a 2-dimensional vector or a single long one. I'm interested in how to implement both. So I'd like to be able to do this:
4 5 divs2 i.20
and have my verb return:
0 4 8 16 20
0 5 10 15
or:
0 4 8 16 20 0 5 10 15
Something like map
or mapcat
or flatmap
from FP languages. How can I achieve this?
EDIT: to be clear, I'm hoping for 2 new verbs (not a single one which can produce both results)