Dictionary Container (#dict)

General:. The dictionary container is a balanced binary tree designed for quick access by key. Dictionaries contain associations. Dictionary associations have unique keys and associated values. A common use of a dictionary would be table of Social Security Number(SSN) / Person's Name pairs. Each person has one and only one SSN. Each SSN number has one and only one name associated with it. The #dict operator creates a dictionary which you then assign to a variable. In the niladic case, the dictionary is maintained in memory. In the monadic case, a file object left argument defines the external storage for the data. In this case, the complete dictionary resides on the file and fragments of the tree reside in memory as you access the dictionary. In both cases, when the dictionary object is deleted or replaced by another object, the dictionary is expunged from memory. In the file case the dictionary persists on the file.

Commentary Code Result
Commentary #dict =>d;
'value'=>['key']d;
d['key']%**$;
d:seq %**$;
Seq[R1C1:K]
[1]String[R2C5:C]value
Seq[R2C1:K]
[1]Seq[R1C2:K]
*[1]String[R2C3:C]key
*[2]String[R2C5:C]value
Commentary #dict =>d;
'av'=>['ak']d;
'bv'=>['bk']d;
'bvnew'=>['bk']d;
'<1>'(d['ak']%**)$;
'<2>'(d['bk']%**)$;
'<3>'(d['ck']$** =noValue%**)$;
'<4>'(d['ck']<$** =noValue%**)$;
'<5>'(d['ak''bk']%**)$;
<1>Seq[R1C1:K]
[1]String[R2C2:C]av
<2>Seq[R1C1:K]
[1]String[R3C5:C]bvnew
Seq[R1C1:K]
[1]NV:
<3>Bit[R1C1:B]0
NV:
<4>Bit[R1C1:B]1
<5>Seq[R1C2:K]
[1]String[R2C2:C]av
[2]String[R3C5:C]bvnew
Commentary #dict =>d;
'<1>'$;
'one''two''three'=>[1 2 3]d;
d[3 1 2]%**$;
'<2>'$;
1 2 3=>['uno''dos''tres']d;
d[1 2 3]%**$;
'<2a>'$;
d['tres''uno''dos''tres']%**$;
'<3>'$;
'three'=>['tres''drei']d;
d['tres''drei']%**$;
'<4>'$;
1 2=>['I''II''III']d;
d['I''II''III'] %**$;
<1>
Seq[R1C3:K]
[1]String[R2C5:C]three
[2]String[R2C3:C]one
[3]String[R2C3:C]two
<2>
Seq[R1C3:K]
[1]String[R2C3:C]one
[2]String[R2C3:C]two
[3]String[R2C5:C]three
<2a>
Seq[R1C4:K]
[1]Num[R3C1:I]3
[2]Num[R2C1:I]1
[3]Num[R2C1:I]2
[4]Num[R3C1:I]3
<3>
Seq[R1C2:K]
[1]String[R4C5:C]three
[2]String[R4C5:C]three
<4>
Seq[R1C3:K]
[1]Num[R2C1:I]1
[2]Num[R2C1:I]2
[3]Num[R2C1:I]Nil
Commentary #dict =>d;
1 2 3=>[1 2 3]d;
'<1>'$;
d:seq %**$;
'<2>'$;
d ~ 2 ;
d:seq %**$;
'<3>'$;
d[2]< = NV$;
<1>
Seq[R2C3:K]
[1]Seq[R1C2:K]
*[1]Num[R2C1:I]1
*[2]Num[R2C1:I]1
[2]Seq[R1C2:K]
*[1]Num[R2C1:I]2
*[2]Num[R2C1:I]2
[3]Seq[R1C2:K]
*[1]Num[R2C1:I]3
*[2]Num[R2C1:I]3
<2>
Seq[R2C2:K]
[1]Seq[R1C2:K]
*[1]Num[R2C1:I]1
*[2]Num[R2C1:I]1
[2]Seq[R1C2:K]
*[1]Num[R2C1:I]3
*[2]Num[R2C1:I]3
<3>
1
Commentary #dict =>d;
'<1>'$;
1 2 3=>[1 2 3]d;
d:seq %**$;
'<2>'$;
d ~(1 2);
d:seq %**$;
<1>
Seq[R2C3:K]
[1]Seq[R1C2:K]
*[1]Num[R2C1:I]1
*[2]Num[R2C1:I]1
[2]Seq[R1C2:K]
*[1]Num[R2C1:I]2
*[2]Num[R2C1:I]2
[3]Seq[R1C2:K]
*[1]Num[R2C1:I]3
*[2]Num[R2C1:I]3
<2>
Seq[R2C1:K]
[1]Seq[R1C2:K]
*[1]Num[R2C1:I]3
*[2]Num[R2C1:I]3
Commentary #dict =>d;
1 'one' =>['one']d;
2 'two' =>['two']d;
'<1>-----------'$;
(d:seq %**)$;
#dict =>dcopy;
d:seq =>[]dcopy;
'<2>-----------'$;
(dcopy:seq %**)$;
<1>-----------
Seq[R2C2:K]
[1]Seq[R1C2:K]
*[1]String[R2C3:C]one
*[2]Seq[R2C2:K]
**[1]Num[R1C1:I]1
**[2]String[R1C3:C]one
[2]Seq[R1C2:K]
*[1]String[R2C3:C]two
*[2]Seq[R3C2:K]
**[1]Num[R1C1:I]2
**[2]String[R1C3:C]two
<2>-----------
Seq[R2C2:K]
[1]Seq[R1C2:K]
*[1]String[R4C3:C]one
*[2]Seq[R4C2:K]
**[1]Num[R1C1:I]1
**[2]String[R1C3:C]one
[2]Seq[R1C2:K]
*[1]String[R4C3:C]two
*[2]Seq[R4C2:K]
**[1]Num[R1C1:I]2
**[2]String[R1C3:C]two
Commentary #dict =>d;
1=>['one']d;
d:seq$**;
d%->> :hex$;