Documentation
API
Dict

Dict

Squiggle dictionaries work similar to Python dictionaries. The syntax is similar to objects in Javascript.

Conversions

toList

Signatures
Dict.toList(Dict('A)) => List([String, 'A])
Examples
Dict.toList({a: 1, b: 2})

fromList

Signatures
Dict.fromList(List([String, 'A])) => Dict('A)
Examples
Dict.fromList([
      ["foo", 3],
      ["bar", 20],
    ]) // {foo: 3, bar: 20}

Transformations

set

Creates a new dictionary that includes the added element, while leaving the original dictionary unaltered.

Signatures
Dict.set(Dict('A), key: String, value: 'A) => Dict('A)
Examples
Dict.set({a: 1, b: 2}, "c", 3)

delete

Creates a new dictionary that excludes the deleted element.

Signatures
Dict.delete(Dict('A), key: String) => Dict('A)
Examples
Dict.delete({a: 1, b: 2}, "a")

merge

Signatures
Dict.merge(Dict(any), Dict(any)) => Dict(any)
Examples
first = { a: 1, b: 2 }
snd = { b: 3, c: 5 }
Dict.merge(first, snd)

mergeMany

Signatures
Dict.mergeMany(List(Dict(any))) => Dict(any)
Examples
first = { a: 1, b: 2 }
snd = { b: 3, c: 5 }
Dict.mergeMany([first, snd]) // {a: 1, b: 3, c: 5}

map

Signatures
Dict.map(Dict('A), fn: ('A) => 'B) => Dict('B)
Examples
Dict.map({a: 1, b: 2}, {|x| x + 1})

mapKeys

Signatures
Dict.mapKeys(Dict('A), fn: (String) => String) => Dict('A)
Examples

omit

Creates a new dictionary that excludes the omitted keys.

Signatures
Dict.omit(Dict('A), List(String)) => keys: Dict('A)
Examples
data = { a: 1, b: 2, c: 3, d: 4 }
Dict.omit(data, ["b", "d"]) // {a: 1, c: 3}

Queries

has

Signatures
Dict.has(Dict(any), key: String) => Bool
Examples
Dict.has({a: 1, b: 2}, "c")

size

Signatures
Dict.size(Dict(any)) => Number
Examples
Dict.size({a: 1, b: 2})

keys

Signatures
Dict.keys(Dict(any)) => List(String)
Examples
Dict.keys({a: 1, b: 2})

values

Signatures
Dict.values(Dict('A)) => List('A)
Examples
Dict.values({ foo: 3, bar: 20 }) // [3, 20]

pick

Creates a new dictionary that only includes the picked keys.

Signatures
Dict.pick(Dict('A), keys: List(String)) => Dict('A)
Examples
data = { a: 1, b: 2, c: 3, d: 4 }
Dict.pick(data, ["a", "c"]) // {a: 1, c: 3}