JanetDocsPlaygroundI'm feeling luckyGitHub sign in

invert



    function
    boot.janet on line 1324, column 1

    (invert ds)

    Returns a table where the keys of an associative data structure are
    the values, and the values of the keys. If multiple keys have the
    same value, one key will be ignored.


4 examplesSign in to add an example
Loading...
(invert :yo)
# => @{121 0 111 1}
sogaiuPlayground
(invert "yo")
# => @{121 0 111 1}
sogaiuPlayground
(invert [:ant :bee :elephant :fox :penguin])
# => @{:bee 1 :fox 3 :elephant 2 :ant 0 :penguin 4}
sogaiuPlayground
(invert {:a 1 :b 2 :c 3})
# => @{3 :c 1 :a 2 :b}
sogaiuPlayground