NB. J gotchas
NB. ischtche%uwaterloo.ca
NB. a short list of weird gotchas and other quirks you should be aware of
NB. they appear to be by design, but they violate expectation, and that's bad
NB. amend indexing: u} vs m}
99 (1}) i. 3 4 NB. m} uses {-style indexing
99 1:} i. 3 4 NB. u} indexes the ravel of y
99 [`1:`]} i. 3 4 NB. gerund m} acts like u}
famend =: (`{)(`(i.@$@]))(`:6)} NB. tacit of 1 : '(u { i.@$@])}'
99 1:famend i. 3 4 NB. a fixed amend for verbs
NB. relevant dictionary pages:
NB. Voc: m}
NB. Voc: u}
NB. script quirkiness: concerning variables x y u v m n in .ijs files
v =: v@, ` [ @. (10 < #) {: NB. a recursively defined verb
NB. using this at the console is fine
NB. using it in a script (external file) is not!
NB. you are not allowed to use x y u v m n freely in a script, because J treats
NB. script files (.ijs) like (0 : 0) scripts and thus has special handling for
NB. the variables x y u v m n; they would normally be filled in when used in a
NB. (1 2 3 4 :)-style definition, so J flips out if they're not
NB. 2015-01-29 note to self: x y u v m n ignored by 4!:1 also
NB. investigate extent of the nonsense
NB. the solution is just to use different names ¯\(°_o)/¯
NB. relevant dictionary pages:
NB. Dic: II.H
NB. comments are picky: careful when inflecting NB
NB. this is a comment
NB.. this is a spelling error!
NB.: and so is this
NB. when J tokenizes its input, inflections (trailing . and :) are all gathered
NB. together into a token, and comments only begin if the token at that point
NB. is exactly 'NB.'; technically J doesn't token the NB. separately, but the
NB. point remains that NB.. is a reserved word, not the start of a comment
NB. when in doubt, consult monad ;: with your string
NB. relevant dictionary pages:
NB. Voc: ;:
NB. order of fork operations: unspecified whether it's unspecified
rs=:3 :'i=:0'
ct=:3 :'i=:1+i'
(ct,ct) 0 [ rs'' NB. 2 1... but potentially 1 2?
(ct 0),(ct 0) [ rs'' NB. 2 1
(ct 0), ct 0 [ rs'' NB. 1 2
NB. it FEELS like there's a precedent for the h in (f g h) to run first, and
NB. there IS an explanation for why the last line seems backwards (hint: when
NB. can the parser ever match RPARs?), compared to the second line, but in
NB. theory f and h can be run parallel, with only g is guaranteed to come
NB. afterwards. the documentation actually has nothing to say on the matter.
NB. the "solution" is just don't try to be clever by using verbs that have
NB. side-effects in a tacit way. as soon as you make any assignments or use !:
NB. at all, J stops being algebraic and turns into an impure mess.
NB. relevant(?) dictionary pages:
NB. Dic: II.E
NB. Dic: II.F
NB. J4C: 27