[Jprogramming] Tacit definition using Amend
Dan Bron
jf at dbron.net
Thu Feb 9 23:45:04 HKT 2006
Donn,
I think I intended that "it's difficult" for the implementor of J (Roger) to design an adverb such that it can be used tacitly, allowing for any of its 3 arguments to be calculated. Not to deter you ;)
The foreign 5!:2 is not a one to one mapping (different inputs can produce identical outputs). For example, the bane of newbies:
scalar =. 1
vector =. ,1
character =. '1'
, 5!:2 ;: 'scalar vector character'
+-+-+-+
|1|1|1|
+-+-+-+
To address this problem, the foreign 5!:0 is introduced. Unlike 5!:2 , it does guaruntee unique outputs for unique inputs. In your example, the clue lies in the differences of the atomic representations:
> ││ ││┌─┬────────────────┐│││
> ││ │││0│┌──┬─────────┬─┐││││
vs:
> ││ ││┌─┬────────────────┐│││
> ││ │││3│┌──┬─────────┬─┐││││
In atomic form, the left hand box in a pair tells you what class of what's contained in the right hand box (though be careful, because the implementation contains bugs).
Specifically, 5!:0 is telling you that there are certain sets of nouns (class 0 ) and verbs (class 3 ) that have identical displays. In this case, it's a gerund (noun) versus a train (verb):
averb =. 1: 2: 3:
anoun =. 1:`2:`3:
averb 0
2
anoun 0
|syntax error
| anoun 0
5!:2 ;: 'averb anoun'
+--+--+--+
|1:|2:|3:|
+--+--+--+
|1:|2:|3:|
+--+--+--+
-Dan
More information about the Programming
mailing list