mirror of
https://github.com/janet-lang/janet
synced 2026-09-14 21:31:20 +00:00
Add frequencies to core library.
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# Get the number of occurences of elements in a set
|
||||
|
||||
(defn frequencies
|
||||
"Get the number of occurences of each value in a indexed structure."
|
||||
[ind]
|
||||
(def freqs @{})
|
||||
(loop
|
||||
[x :in ind]
|
||||
(def n (get freqs x))
|
||||
(put freqs x (if n (+ 1 n) 1)))
|
||||
freqs)
|
||||
Reference in New Issue
Block a user