I created a dyadic verb that expects a number and a vector and returns a vector filtered to contain those that divide the number, for example:
divs =. 4 : '((=<.)y%x)#y'
So, for example, 4 divs i.20 returns 0 4 8 12 16 as expected.
Now I would like to change / wrap this verb so that the first argument could be a vector, and return either a two-dimensional vector or one long one. I'm interested in how to implement both. Therefore, I would like to be able to do this:
4 5 divs2 i.20
and return my verb:
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 hope for 2 new verbs (not one that can give both results)
source share