>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# map: map
[nested] map of (,: key;value) entries FLAT MAPS creating a map:

      MAP=: empty''                      NB. you should've guessed!
      MAP=: 1 2 3 'one' setmap empty''   NB. with some values
      MAP=: ('k1';i.3),:('k2';'qq')      NB. declaratively

    k1

    0 1 2

    k2

    qq
changing values:

      MAP=: (i.3 4) 'k2' setmap MAP      NB. similar to amend, "}"

    k1

    0 1 2

    k2

    0 1  2  3

    4 5  6  7

    8 9 10 11
adding values:

      MAP=: 'qq' 'k3' setmap MAP         NB. same as setting

    k1

    0 1 2

    k2

    0 1  2  3

    4 5  6  7

    8 9 10 11

    k3

    qq
removing entries:

                                   NB. i.e. setting to nothing
      MAP=: 'k2' setmap MAP        NB. graceful for missing keys

    k1

    0 1 2

    k3

    qq
getting values:
                                   NB. similar to From '{'
      VALUE=: 'k1' getmap MAP      NB. missing keys gracefully return empty''
    0 1 2

       getmap MAP                 NB. catalog of keys, like '{'

    k1

    k2

    k3
index of the key:
      INDEX=: 'k4' ndxmap MAP
existance of key:
      BOOL=: 'k4' hasmap MAP
NESTED MAPS build a nested map:

      MAPX=: 3 'k2.k6' setmapx 'val' 'k2.k4' setmapx 1 'k1.k3' setmapx empty''
      MAPX=: 3 'k2.k4.k8' setmapx (i.3 4) 'k1.k5' setmapx MAPX

    k1

    k3

    1

    k5

    0 1  2  3

    4 5  6  7

    8 9 10 11

    k2

    k4

    val

    k8

    3

    k6

    3
removing nested entries:

                                   NB. i.e. setting to nothing
       'k1.k5' setmapx 'k2' setmapx MAPX

    k1

    k3

    1
value of deep key from nested map:

       'k1.k3' getmapx MAPX
    1
       'k2.k4' getmapx MAPX

    val

    k8

    3

       'k2.k4.' getmapx MAPX
    val

       getmapx MAPX               NB. catalog of nested keys, like '{'

    k1.k3

    k1.k5

    k2.k4.

    k2.k4.k8

    k2.k6

       flatmap MAPX                NB. covert nested map to flat

    k1.k3

    1

    k1.k5

    0 1  2  3

    4 5  6  7

    8 9 10 11

    k2.k4.

    val

    k2.k4.k8

    3

    k2.k6

    3
       MAPX -: flatmapx flatmap MAPX      NB. reverse of flattening
    1
       strmap MAPX        NB. covert nested map to multiline string
    k1.k3    1            NB. useful for storing and restoring config
    k1.k5    i.3 4
    k2.k4.   'val'
    k2.k4.k8 3
    k2.k6    3
       MAPX -: strmapx strmap MAPX        NB. reverse from string
    1
    CMAP=: 0 : 0                  NB. build nested map from COMPACT string
    k1 .k3  1     .k5    i.3 4
    k2 .k4. 'val' .k4.k8 3     .k6 3
    )
       MAPX -: strmapc CMAP
    1
AUTHOR
       (C) Oleg Kobchenko , 10/12/2003
           GPL, AS-IS, NO WARRANTY
       10/23/2003 added strmap[x|c]
Name | Type | Description
DELIM | verb | nested keys delimiter
flatmap | verb | convert nested map to flat map of leaves
flatmapx | verb | convert flat map to nested
getmap | verb | [dyad] value for a key
getmap | verb | [monad] list map keys
getmapx | verb | [dyad] value for a deep nexted key
getmapx | verb | [monad] list nested map keys
hasmap | verb | existance of the key
ismap | verb | being a map
ndxmap | verb | index of the key
setmap | adverb | [dyad] add/change map value
setmap | adverb | [monad] remove map entry
setmapx | adverb | [dyad] add/change value for a deep nexted key
setmapx | adverb | [monad] remove a nested entry
strmap | verb | convert nested map to multiline string
strmapc | verb | convert compact string to nested map
strmapx | verb | convert multiline string to nested map
DELIM
    nested keys delimiter
    in 'k1.k2.k3' DELIM=: '.' (default)
flatmap
    convert nested map to flat map of leaves
    MAP=: flatmap MAPX
flatmapx
    convert flat map to nested
    MAPX=: flatmapx MAP
getmap
    [dyad] value for a key
    VALUE=: 'key' getmap MAP
getmap
    [monad] list map keys
    KEYS=: geymap MAP
getmapx
    [dyad] value for a deep nexted key
    VALUE=: 'k1.k2.k3' getmapx MAPX
getmapx
    [monad] list nested map keys
    KEYS=: geymapx MAP
hasmap
    existance of the key
    BOOL=: 'key' hasmap MAP
ismap
    being a map
    BOOL=: ismap MAP
ndxmap
    index of the key
    INDEX=: 'key' ndxmap MAP
setmap
    [dyad] add/change map value
    MAP=: VALUE 'key' setmap MAP
setmap
    [monad] remove map entry
    MAP=: 'key' setmap MAP
setmapx
    [dyad] add/change value for a deep nexted key
    MAPX=: VALUE 'k1.k2.k3' setmapx MAPX
setmapx
    [monad] remove a nested entry
    MAPX=: 'k1.k2.k3' setmapx MAPX
strmap
    convert nested map to multiline string
    STR=: strmap MAPX
strmapc
    convert compact string to nested map
    MAPX=: strmapc CSTR

    Compact string representation of a nested map is an extension
    of multiline string (strmap), except it allows multiple keys per line.

    Each line of compact string consists of
    stem .tail1 value1 .tail2 value2  ...
      stem:   first non-space chars,
              forms beggining of the key
      tailI:  non-space chars preceded with ' .'
              forms end of key
      valueI: value of the key

    Both stem and tails may contain multiple parts of the key,
    separated with '.', but it's important that tails always
    begin with a '.'
strmapx
    convert multiline string to nested map
    MAPX=: strmapx STR
>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User