[Jprogramming] Grammar question: 2: * i.
Elijah Stone
elronnd at elronnd.net
Tue Oct 19 07:13:55 UTC 2021
A single digit followed by a colon is a _constant verb_, which always
produces the same result no matter its operand. For example:
f=. 2:
f 5
2
f 7 7
2
3 f 'a'
2
So, '2: * i.' is a V V V fork, whereas '2 * i.' is an N V V fork. I guess
that the latter were not yet implemented when that entry of the phrasebook
was written.
FWIW the functions are documented in NuVoc; the entry link is titled '_9:
to 9:; Constant Functions', and can be read at
https://code.jsoftware.com/wiki/Vocabulary/zeroco
There is also a dictionary entry:
https://www.jsoftware.com/help/dictionary/dconsf.htm
-E
On Tue, 19 Oct 2021, Jon Quant wrote:
> Hi all,
>
> The J phrases book has simple uses of colon which I can't find in the NuVoc
> grammar.
> Could someone help explain the grammar of the following?
>
> Verb trains:
>
> even=: 2: * i.
> odd=: 1: + 2: * i.
>
> These seem to work without the colons anyway. What is the grammar rule and
> purpose for an integer followed by a colon?
>
> Great fun so far with J!
>
> Thanks
>
> Jon
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list