57 lines
1.2 KiB
Plaintext
57 lines
1.2 KiB
Plaintext
1) a (currently) reduced set of functions:
|
|
|
|
HASH: [5] [H.lib, H.new, H.disp, H.get, H.set!]
|
|
|
|
2) building an associative array: {def H key value | ...}
|
|
|
|
{def capitals
|
|
{H.new nyk New York, United States |
|
|
lon London, United Kingdom |
|
|
par Paris, France |
|
|
mos Moscou, Russia }}
|
|
-> capitals
|
|
|
|
3) displaying: {H.disp hash}
|
|
{H.disp {capitals}}
|
|
->
|
|
[
|
|
nyk: New York, United States
|
|
lon: London, United Kingdom
|
|
par: Paris, France
|
|
mos: Moscou, Russia
|
|
]
|
|
|
|
4) getting a value from a key: {H.get hash key}
|
|
|
|
{H.get {capitals} nyk} -> New York, United States
|
|
{H.get {capitals} lon} -> London, United Kingdom
|
|
{H.get {capitals} par} -> Paris, France
|
|
{H.get {capitals} mos} -> Moscou, Russia
|
|
|
|
5) adding a new (key,value): {H.set! hash key value}
|
|
|
|
{H.disp {H.set! {capitals} bar Barcelona, Catalunya}}
|
|
->
|
|
[
|
|
nyk: New York, United States
|
|
lon: London, United Kingdom
|
|
par: Paris, France
|
|
mos: Moscou, Russia
|
|
bar: Barcelona, Catalunya
|
|
]
|
|
|
|
6) editing a key
|
|
|
|
{H.disp
|
|
{H.set! {capitals}
|
|
nyk
|
|
{H.get {capitals} nyk} of America}} // adding "of America" to nyk
|
|
->
|
|
[
|
|
nyk: New York, United States of America
|
|
lon: London, United Kingdom
|
|
par: Paris, France
|
|
mos: Moscou, Russia
|
|
bar: Barcelona, Catalunya
|
|
]
|