[Jprogramming] symbol index origin
Dan Bron
j at bron.us
Sat Mar 19 12:35:09 UTC 2016
Pascal wrote:
> 6 s:s:'`' NB. Oh! The fill symbol hides.
> 0
Yes, symbol 0 is reserved (unsurprisingly) for the empty symbol, the symbolic equivalent of ‘’, which is the literal equivalent of … 0 (and not just in J, but broadly recognized as such in information theory and the discipline of formal languages).
And, just like 0 in numerical arrays and ‘ ‘ in literal arrays and a: in boxed arrays, s:’ ‘ (the empty symbol) is used for fills in symbolic arrays.
If you had wanted, you could have asked J this question directly:
_6 s: 0 NB. Which symbol has index 0 ?
`
Or, less directly, but more cutely:
6 s:^:_1: 0
`
This relationship between (-N)&s: and N&s:^:_1 is intentional, introduced for its mnemonic virtues, and is shared by some other primitives [1].
-Dan
[1] J Chat thread “Conversion”, March 2010, discussing x: and later p: :
http://www.jsoftware.com/pipermail/chat/2010-March/003487.html <http://www.jsoftware.com/pipermail/chat/2010-March/003487.html>
More information about the Programming
mailing list