If you can keep the general exclusive nature of i. then first function is
easier
5 ([ + i.@-~) 20
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
then
steppedinterval =: ([ + i.@-~)/ : (-@[ {.\ ([ + i.@-~)/@]) NB. monadic = step
1
3 steppedinterval 5 20
5 8 11 14 17
On Sunday, March 29, 2020, 05:52:38 a.m. EDT, Rudolf Sykora
<[email protected]> wrote:
Dear all,
how do you usually generate a sequence of integers from 'a' to 'b' with
a step 's'?
If I ignore the step, yesterday I wrote
interval=.{.+(i. @ >: @ ({:-{.))
interval 5 19
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
but that seems overly complicated...
Then I can include the step in this way
_3 {.\ interval 5 19
5 8 11 14 17
Putting the two parts together would make it even more complicated.
There must be a better way...
Thanks
Ruda
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm