2l: Container from Container

+malt

Map from list

Produces a map from a list .a.

Accepts

.a is a list.

Produces

A map.

Source

++  malt                                                ::  map from list
  |*  a=(list)
  (molt `(list [p=_-<.a q=_->.a])`a)

Examples

    > (malt [['ok' 'no'] ['a' 'b'] ['x' 'y'] ~])
    [n=[p='x' q='y'] l={[p='a' q='b'] [p='ok' q='no']} r={}]

    > (malt ~[[1 2 3] [4 5 6] [7 8 9]])
    [n=[p=1 q=[2 3]] l={[p=4 q=[5 6]] [p=7 q=[8 9]]} r={}]

+molt

Map from pair list

Produces a map from a list of pairs .a.

Accepts

.a is a list of pairs.

Produces

A map.

Source

    ++  molt
      |*  a=(list (pair))
      (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)

Examples

    > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
    > a
    > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]

    > (molt a)
    [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]

Discussion

Only used internally as a helper to +malt.


+silt

Set from list

Produces a set from a list .a.

Accepts

.a is a list.

Produces

A set.

Source

    ++  silt
      |*  a=(list)
      =+  b=*(tree _?>(?=(^ a) i.a))
      (~(gas in b) a)

Examples

    > (silt `(list @t)`['c' 'hoon' 'javascript' 'python' ~])
    [n='javascript' l={} r={'python' 'hoon' 'c'}]

Last updated