function
boot.janet on line 2002 , column 1
(group-by f x )
Group values of `x` by a function `f` and put the results into a
new table. The keys of the table are the distinct return values
from calling `f` on the values of `x` . The values of the table are
arrays of all values of `x` for which `f` called on the value
equals that corresponding key.
`x` can be a bytes , indexed , dictionary , fiber , or abstract type
with suitable `get` and `next` methods.
(group-by odd? [1 2 3 5 6 ])
# =>
@{false @[2 6 ] true @[1 3 5 ]}
(group-by
(fn [i ] (i :label ))
[{:label 'A :value 4 } {:label 'A :value 3 } {:label 'B :value 5 }])
# @{A @[{:label A :value 4} {:label A :value 3}] B @[{:label B :value 5}]}