-`+/ will insert alternating - then + between items of argument. Those are
dyadic verbs, and they have to be.
Still the idea of applying monads to alternating items in a list must have
occurred to others too. One technique is:
('+:';'-:') apply each 4 2
┌─┬─┐
│8│1│
└─┴─┘
but this doesn't have the auto expansion that gerunds and / have. A solution
(] ,~ -:@:[)`(] ,~ +:@:[)/ 3 4 2 0
1.5 8 1 0
where the trailing 0 is a pad that doesn't get processed.
With my version of strand notation and double adverbs at
http://www.jsoftware.com/jwiki/PascalJasmin/functional%20algebra%20and%20double%20adverbs%20part%202
This can be made into a clean adverb that adds its own pad, and then removes
the pad after processing. (needs many definitions from that page). all one
line.
altMs =: 'lrT (''[: }: [:''&,)@:(,&''/ {:,~]'')@:(''`''&joinstring)@:(([: ''(]
,~''&, ,&''@:[)'' )each) @:( {."1) v2a eval' aatrain
9: -: +: altMs NB. 9: closes strand input
[: }: [: (] ,~ -:@:[)`(] ,~ +:@:[)`:3 {: ,~ ]
9: -: +: altMs 3 4 5 6 NB. verbs get inserted left to right
1.5 8 2.5 12
9: -: +: *: altMs 3 4 5 6 7
1.5 8 25 3 14
9: *: (-: +: altMs) NB. expression in brackets is assignable adverb
[: }: [: (] ,~ *:@:[)`(] ,~ -:@:[)`(] ,~ +:@:[)`:3 {: ,~ ]
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm