JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

frequencies

core-api


    function
    boot.janet on line 1989, column 1

    (frequencies x)

    Returns a table of occurrences of each value in `x`.

    `x` can be a bytes, indexed, dictionary, fiber, or abstract type 
    with `get` and `next` methods.


1 exampleSign in to add an example
Loading...
(frequencies ["a" "a" "b" "c" "d" "d"])
# => @{"c" 1 "d" 2 "a" 2 "b" 1}


(frequencies {:a "Bob"
              :b "Joe"
              :c "Mat"
              :d "Bob"})
# => @{"Bob" 2 "Joe" 1 "Mat" 1}

(frequencies "Hallo World")
# => @{108 3 114 1 100 1 87 1 97 1 32 1 111 2 72 1}
leobmPlayground