The transition from dyadic to monadic interpretation in the J-sentence
I am trying to understand the composition in J by trying to mix and match the different phases. I would like to help switch between monadic and dyadic phrases in the same sentence.
I just made a simple cube roller in J to serve as an example:
d=.1+[:?[#]
4 d 6
2 3 1 1
8 d 12
10 2 11 11 5 11 1 10
This is a string: "d is the plus plus (limited) move of x occurrences of y"
But what if I wanted to use>: to increment (and skip cap [:) so that it "switches" to monadic interpretation after the first fork? It will read: "d is the roll increment of x occurrences of y".
Something like this doesn't work, although it seems to me that I have the correct structure:
d=.>:&?[#]
d
>:&? ([ # ])
(If this approach is against the grain for J, and I have to stick with closed forks, this is also useful information.)
source to share
Let's look at a dyadic fork a(c d f h g)b
, where c, d, f, g, and h are verbs and a and b are arguments that evaluate to: (a c b) d (a f b) h (a g b)
Arguments are applied binary to verbs in odd position (or tines c, f, and g) - and these results are transmitted dyadically from right to left in even lines d and h. Also, the fork can be either (vvv) or (nvv), where v stands for verbs and n stands for nouns. In the (nvv) case, you just get the value of n as the left argument for the middle tooth.
If you look at your original definition d=.1+[:?[#]
, you may notice that this simplifies a binary fork with five prongs (1 + [: ? #)
, where [ # ]
you can replace it with #
, as it is a dyadic fork (see definition above).
The verb [:
(Cap) does not return a value to the left argument ?
, which means it ?
acts monadically on the result a # b
, and that becomes the correct argument for +
that which has a left argument 1
.
So, to the question of how to get rid of [:
and use >:
instead1 + ...
You can also write ([: f g)
how f@:g
to get rid of the Cap, which means it ([: ? #)
becomes ?@:#
, and now since you want to pipe that result to >:
, you can do it with:
d1=.>:@:?@:#
d2=. [: >: ?@:#
4 d1 6
6 6 1 5
4 d2 6
2 3 4 5
8 d1 12
7 6 6 4 6 9 8 7
8 d2 12
2 10 10 9 8 12 4 3
Hope this helps, this is a good fundamental question about how surebets are priced. It would be preferable to use the form of composition ([: f g)
or f@:g
.
source to share
To summarize the basic simple mixing patterns for verbs in J:
(f @: g) y = f (g y) NB. (1) monadic "at"
x (f @: g) y = f (x g y) NB. (2) dyadic "at"
x (f &: g) y = (g x) f (g y) NB. (3) "appose"
(f g h) y = (f y) g (h y) NB. (4) monadic fork
x (f g h) y = (x f y) g (x h y) NB. (5) dyadic fork
(f g) y = y f (g y) NB. (6) monadic hook
x (f g) y = x f (g y) NB. (7) dyadic hook
A good overview of these is here (compositions) and here (trains) .
There are usually many possible forms for a verb. To complicate matters, you can mix many primitives in different ways to achieve the same result.
Experience, style, performance , and other such factors affect how you combine these above to form your verb.
In this particular case, I would use @bob d1
because I find it clearer increase the roll of x copies of y
::
>: @ ? @ $
For the same reason, I replace #
with $
. When I see it #
in this context, I automatically read "cardinality", but maybe it's just me.
source to share