NB. examples of using a Dictionary

require 'jzdict'             NB. standard dictionary class

NB. =========================================================
NB. create standard dictionary:
d=: '' conew 'jzdict'

NB. add some entries:
putkvp__d ('one';'two';'too many') ; 1;1 2;1 2 3

size__d''                    NB. size of dictionary
get__d 'two'                 NB. get value
get__d 'two';'too many'      NB. get values
getkv__d 'two';'too many'    NB. get keys and values
putkv__d 'two';i.3 4         NB. put new value for existing key
includes__d 'two'            NB. confirm existence of new value
setfill__d 9999              NB. set default value
getp__d 'two';'not there'    NB. permissive get values
hasvalues__d 1;1 2           NB. keys with given values

NB. this replace would fail, since key "todo" is not defined:
NB. putkv__d 'todo';100      NB. fails

NB. correct way to add a new key:
putkvp__d 'todo';100         NB. add new key (permissive put)


NB. =========================================================
NB. create word dictionary:
require 'jwdict'

dw=: '' conew 'jwdict'

NB. its very common to use single words (J tokens) as keys
NB. using a jwdict rather than a jzdict simplifies the usage
NB. of keys

NB. add some entries:
putkvp__dw 'first second third';1;1 2;1 2 3
putkvp__dw 'fourth fifth sixth'; 42 NB. scalar extension
keys__dw                     NB. all keys
size__dw''                   NB. for a jzdict this would be one key
includes__dw 'first two third'
delete__dw 'fifth sixth'     NB. remove keys
delete__dw 'fifth'           NB. will fail, key nolonger exists
deletep__dw 'fifth ninth'    NB. permissive delete
getkv__dw 'second third'     NB. get values
clear__dw''                  NB. remove all keys
isempty__dw''
size__dw''
putkvp__dw 'one one one';1;10;101 NB. multiple add
get__dw'one'                 NB. only the most recent was taken

NB. =========================================================
NB. create numeric dictionary:
require 'jndict'

dn=: '' conew 'jndict'

NB. add some entries:
putkvp__dn 1 2 3;1;1 2;1 2 3

get__dn 1 2                  NB. get values
putkvp__dn 2 3;200;300       NB. add two records
setfill__dn 666
getp__dn 1 2 3 404
exporttofilep__dn 'filename.ijd'   NB. save to file
importfromfile__dn 'filename.ijd'  NB. will fail, as dn is nonempty
importfromfilep__dn 'filename.ijd' NB. to do it anyway or
clear__dn''                        NB. empty it
importfromfile__dn 'filename.ijd'  NB. then import the records
