What is the reference implementation of dictionary AKA hash?
I see 2 alternatives:
One is to use dyadic i.
Something like
cocurrent 'hash'
K=:i.0
V=:i.0
get=:3 : '>(V,a:){~K i. boxopen y'
put=:4 : 0
i=.K i. y=.boxopen y
if. i>:#K do.
V=:V,<x
K=:K,y
else.
V=:(<x) i} V
end.
i. 0 0
)
cocurrent 'base'
I mildly recall that i. has some kind of special code that could help make the
above scheme tolerable for larger sets of keys, but I am not sure which form
triggers this special code.
Another is to use J's built in ability to search for a name in locale. That
would require to nameify arbitrary string and save the value into this name (in
dedicated dictionary locale) using some kind of ". or (expr)=:...
This one just does not feel right.
I would appreciate if someone who already implemented hashes could share his
insights.
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/201469230/direct/01/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm