modifier forks are parsed differently than traditional forks.
Modifer forks longer than 3 times are 3-grouped/parenthesised from
left to right instead of right to left of traditional forks. A mixed
fork is a modifier fork
The last sentence is not accurate. I've attempted to describe the
rules for a mixed (modifier and verb in one) fork/train at:
https://code.jsoftware.com/wiki/Vocabulary/fork#Longer_forks.2Ftrains
Not sure if it is complete or as descriptive as it should be.
On Monday, December 20, 2021, 03:38:15 p.m. EST, 'Pascal Jasmin' via
Programming <[email protected]> wrote:
And presumably there's some use for having the ability to carry around
a partially constructed fork.
A likely bigger advantage than parentheses avoidance.
for a tutorial, I should probably have included the bible on modifier
trains earlier on the
thread: https://code.jsoftware.com/wiki/Vocabulary/fork#invisiblemodifiers
modifier forks are parsed differently than traditional forks. Modifer
forks longer than 3 times are 3-grouped/parenthesised from left to
right instead of right to left of traditional forks. A mixed fork is
a modifier fork
(+/ % # @ @)
(+/ % #) @ @
the most useful partially constructed fork (or any longer than 2
param modifier) "constructor"/compound modifer is one that provides
binding flexibility.
The "native" modifier trains are already pretty complete. They can be
categorized into more useful/less useful categories. The more useful:
A V NB. allows compound adverb modifier to bind V if it returns a
conjunction. (or create hook)
A V V NB. simple fork with 1 parameter. or ]:WU in your world. if VWU
wanted instead then ]:W~U
[. V ]. NB. conjunction with center param fixed
AAV NB. where AAV is (]: ]: V )then it is U (]: ]: V)W a ~ allows V
(]: (]:~) U) W
The last 2 are conjunctions with either a center or outter tine
fixed. This is the same as my F0 F1 F2 adverbs when they are fixed.
But F0 F1 F2 are more flexible in that they allow hook formation or by
passing the ars of modifiers, for purposes of modifier train forming.
F0 F1 F2 also allow binding first choice of 2 out of 3 possible
parameters. Conceptually, F0 F1 F2 are used because of a specificaly
desired first binding, and when that natural choice is made (U F0), (W
F1) or (V F2) then there is full choice in binding one of the
remaining 2 params.
A final completing native adverb train completer is:
(U(]:]:V)) NB. adverb where W is final parameter completing the adverb
range: AVV and AV~V
These 3 are the same as F01 F02 and F=:F12. The advantage of the Fmn
variants is they allow binding either one of the first 2 UWVs it
"specializes" for, and the hook + modifier ars to create modifier trains.
The less useful "native" modifer fork forming trains.
CVV -> (uCv)VV NB. [:VV would allow uCv to be passed with user choice
of C. Still useful if C genuinely "wants to be" fixed.
VVC -> mirror of above that could just be CV~V
W 'C' aar F0 U reproduces the first one. or
+/ -'@' aar F % F # NB. native with @ given requires ([. ([. @ ].) ].)
+/ -@% #
+/ -([. ([. @ ].) ].) % # NB. cool that this works.
+/ -@% #
The F0 F1 F2 F01 F02 F12 compound modifiers provide less typing and
more flexibility (`:6 is J superpower) than the native fork forming
modifiers. But, if you don't want to learn them then the native
versions are self documenting if you understand them. ie. named
functions you are unfamiliar with always means looking them up (and
then understanding them)
On Sunday, December 19, 2021, 10:16:13 p.m. EST, Raul Miller
<[email protected]> wrote:
For most purposes, zero fork constructing words are necessary. And,
UW2V=: {{)c
{{)c
v=. {{
0!:0'u=.',m
u
}}
u (0{::n)v (1{::n)v
}}((5!:5<'u');5!:5<'v')
}}
should be adequate for most of the examples where a fork producing
word is necessary.
But, personally, I don't do these things because they are necessary. I
do them for fun.
$ ;UW2V ,
$ ; ,
Hopefully it's obvious that I could have gotten the same result with
$ ; ,
$ ; ,
That said, note that if instead of the 9!:3]5 which I have in my
profile.ijs, I used some other verb display form, that that result
would display different:
9!:3]1
$ ; ,
+-----------+
|+-+-------+|
||3|+-+-+-+||
|| ||$|;|,|||
|| |+-+-+-+||
|+-+-------+|
+-----------+
9!:3]4
$ ; ,
+- $
--+- ;
+- ,
I would say "of course", but I don't know how a beginner would know
about this mechanism if they were not treated to a suggestion to try
it.
Still, I am fond of
9!:3]5
Anyway, back to the topic... we can do:
ex1=: ;UW2V ,
ex2=: ,(;UW2V)
$ ex1
$ ; ,
$ ex2
$ ; ,
And presumably there's some use for having the ability to carry around
a partially constructed fork.
But is UW2V automatically superior to UWV1? (Defined earlier today:
http://jsoftware.com/pipermail/programming/2021-December/059410.html#)
ex3=: ; , UWV1
$ ex3
$ ; ,
The construction of ex2 and ex3 are only superficially similar, since
ex2 needs a set of parenthesis. And, on these forums, elimination of
parenthesis has often been declared to be a highly important issue.
So... there's that...
------------------------------
Finally, I should correct a statement I had made previously:
This was wrong: "If you use parentheses, U W UW2V V would be
equivalent to V (U W UW2V)."
This turns out to be false. In older versions of J (if an
implementation of UW2V had been written in that style), this would
have been equivalent to (U W) UW2V V. But in J903, (U W UW2V) is a
conjunction, not an adverb. And, using that conjunction results in a
syntax error. I haven't worked through the details yet, of why this
happens.
Thanks,
--
Raul
----------------------------------------------------------------------
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