I like Pascal's style point that verbs with two parameters (e.g. sum and
list) should be dyadic. I also like Rob's proposal to name verbs that
perform basic functions.

Two verbs that I find I use quite often, at least in solving Quora math
questions, are sep and to:

sep=.10#.inv] NB. Separate the digits in a list of integers.

to=:[+i.@:>:@-~ NB. Generate a list of integers, starting from the left
argument to the right argument.

So Pascal's dyadic verb becomes:

5 (]#~[=+/"1@sep) 100 to 999

104 113 122 131 140 203 212 221 230 302 311 320 401 410 500


6 (]#~[=+/"1@sep) 100 to 999

105 114 123 132 141 150 204 213 222 231 240 303 312 321 330 402 411 420 501
510 600


NB. Or if you use that sum digits verb a lot, name the whole thing:

sumd=.]#~[=+/"1@sep


7 sumd 10 to 99

16 25 34 43 52 61 70


Skip

Skip Cave
Cave Consulting LLC


On Wed, Jan 16, 2019 at 8:14 AM 'Pascal Jasmin' via Programming <
[email protected]> wrote:

> just a style/design point,
>
> The parameters for a dyadic verb s/would be the 5 (sum) and whatever list
> to scan.
>
> 5 (] #~ [ = +/"1@(10 #.^:_1 ])) 10+i.900
> 14 23 32 41 50 104 113 122 131 140 203 212 221 230 302 311 320 401 410 500
>
>
> 6 (] #~ [ = +/"1@(10 #.^:_1 ])) i.900
> 6 15 24 33 42 51 60 105 114 123 132 141 150 204 213 222 231 240 303 312
> 321 330 402 411 420 501 510 600
>
>
> ________________________________
> From: 'robert therriault' via Programming <[email protected]>
> To: Programming forum <[email protected]>
> Sent: Wednesday, January 16, 2019 2:42 AM
> Subject: Re: [Jprogramming] Implicit Coding
>
>
>
> Hey Skip,
>
> A couple of different options (all dyadic verbs with arguments of 100 and
> 900)
>
>     100 ((+ i.) #~ (5 = +/"1)@:(10 #.^:_1 (+ i.))) 900         NB. pretty
> much a transcription without the assignment
> 104 113 122 131 140 203 212 221 230 302 311 320 401 410 500
>    100 (#~ (5 = +/"1)@:(10 #.^:_1 ]))@:(+ i.) 900              NB.
> Eliminate redundant (+ i.) by making into consecutive hooks
> 104 113 122 131 140 203 212 221 230 302 311 320 401 410 500
>    100 (#~ (5 = +/"1) @:(10&#.^:_1))@:(+ i.) 900               NB. Convert
> (10 #.^:_1 ]) fork into single verb (10&#.^:_1)
>
> Cheers, bob
>
>
> > On Jan 15, 2019, at 11:12 PM, 'Skip Cave' via Programming <
> [email protected]> wrote:
> >
> > a#~5=+/"1]10#.^:_1 a=:100+i.900
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to