[Jprogramming] Just for fun, verb cross
Raul Miller
rauldmiller at gmail.com
Mon Dec 10 21:17:15 UTC 2012
Yes...
The precedence rule for conjunctions is different when no right
argument is provided. In that case, the conjunction has lower
precedence than anything else in the language. It's as if there's a
"free parenthesis" to its left.
In other words
+.|.@
is equivalent to
(+. |.)@
The reasons for this are documented in
http://www.jsoftware.com/help/dictionary/dicte.htm but this part of
the grammar does not get much use here on the forums, so it's worth a
note of explanation:
The "Conj" grammar requires a right argument, and if a right argument
is not present we use "Bident" instead. And Bident only works when
the left edge is a part of the production, so the conjunction gets
ignored until then.
As an aside, I have not thought about why we have "0 Monad" -- why the
Bident rule is not used to handle that case. Can anyone think of a
mechanical reason? Or is it just emphasis?
Thanks,
--
Raul
On Mon, Dec 10, 2012 at 4:01 PM, David Ward Lambert
<b49P23TIvg at stny.rr.com> wrote:
> Without looking studying the sentence evaluator, I expected
>
> +.|.@
> (+. |.)@
>
> to be identical to
> +.(|.@)
> |. at +.
>
>
>> Date: Mon, 10 Dec 2012 15:41:52 -0500
>> From: Raul Miller <rauldmiller at gmail.com>
>> To: programming at jsoftware.com
>> Subject: Re: [Jprogramming] Just for fun, verb cross
>> Message-ID:
>> <CAD2jOU8iKSKDjgPuPf26_wqUSd3QOgscqLcXkCtMC0xZj2o
>> +oQ at mail.gmail.com>
>> Content-Type: text/plain; charset=UTF-8
>>
>> For what it's worth, here's a parenthesis free implementation of my
>> two variant definitions of cross (and note that I am using what is
>> probably an unfamiliar J idiom here -- please feel free to ask for an
>> explanation, if I am not making sense):
>>
>> selch=: #"0"1
>> orflp=: +.|.@
>> cross1=: , at selch~ = orflp
>>
>> cross2=: , at selch~ =@i.@# orflp
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list