Applying an adverb to a list of gerunds

Consider the list of gerunds and some data to which we want to apply them cyclically:

ms=.*`+`-     NB. list of gerunds
d =.3 4 5 6   NB. some data

We can do it:

ms/ d    NB. returns 9, ie, the result of 3 * 4 + 5 - 6

Now we ask the question: how does the result change if we change the order in which we apply the verbs? That is, we will consider all 6 possible orders:

allms=. (A.~i.@!@#) ms

which is as follows:

┌─┬─┬─┐
│*│+│-│
├─┼─┼─┤
│*│-│+│
├─┼─┼─┤
│+│*│-│
├─┼─┼─┤
│+│-│*│
├─┼─┼─┤
│-│*│+│
├─┼─┼─┤
│-│+│*│
└─┴─┴─┘

To answer the question, we can do:

allms (4 : 'x/ y')"1 d

NB. returns 9 _21 _1 _23 _41 _31

But I noticed that for this I was forced to use an anonymous, unspoken verb. Because to apply the dialect, /I had to have a named verb. When what I really wanted to do was treat /as a rank 1 verb and “match” it over my list allms, something in the spirit of an illegal wording:

/&d"1 allms  NB. This is invalid J

gerund / d.

J, , " , ". , .

, gerunds ms data d, . , ms/ d ms (.. , 9 _21 _1 _23 _41 _31 ). .

+4
2

,

, ( ).

, , , /, "1, J. , , (.. ) sup1; , & sup2;.

, gerunds, , , . doog script, J Wiki SVN.

doog script, , sup3;.  , :

   D       =.   foo`bar`baz 
   t       =.   D / (@:])  NB. Here our "over" (/)

   over    =.  [^:(D -: ]) L: (L.D) & (5!:1<,'t')
   allOver =:  (]^:[~ 1:`'' , over f.)~


   3 4 5 6 allOver"1~ (A.~i.@!@#) *`+`-       NB. Note the "1
9 _21 _1 _23 _41 _31

, ]^:[, ^: .

, some_atomic_rep f^:[ data f^:some_atomic_rep data, rep - , ( , ).

- (: ) ( , ) , ^:.

D / (@:]), D gerund ( @:], , gerund , : , D, , D) 4.

Lasciate ogne speranza

Ultima Thule , dont J, do (".), ... , .


& 1; : , wordclasses.

& sup2; , "" , J- F ^ 4 ( Fixable Functional Faction), , . . "J Myths Puzzles" 2008 ( ). , , .

& sup3; - : ", dcog , : . ".

4 : gerund foo`bar`baz , , , . . , , , , undefined ( , ). - . , __ - ( ____).

+2
ms=.*`+`-     NB. list of gerunds
d =.3 4 5 6   NB. some data
allms=. (A.~i.@!@#) ms

" ", gerunds

*`+`-

'/', 128!:2 (Apply), , , , . , allms .

, :

   [ ger=. ,&'/' @ }: @ (1j1 #!.'`' ;)"1 allms
*`+`-/
*`-`+/
+`*`-/
+`-`*/
-`*`+/
-`+`*/

, 128!:2 ()

   ger  128!:2 d
9 _21 _1 _23 _41 _31

   gvt=. ,&'/'@ }:@(1j1 #!.'`' ;)"1 @: [ 128!: 2 ] 
   allms gvt d
9 _21 _1 _23 _41 _31

, , , .

+1

Source: https://habr.com/ru/post/1681072/


All Articles