JanetDocsPlaygroundI'm feeling luckyGitHub sign in

group-by



    function
    boot.janet on line 1581, column 1

    (group-by f ind)

    Group elements of `ind` 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 elements of `ind`. The values of the table 
    are arrays of all elements of `ind` for which `f` called on the 
    element equals that corresponding key.


2 examplesSign in to add an example
Loading...
(group-by odd? [1 2 3 5 6])
# =>
@{false @[2 6] true @[1 3 5]}
uvtcPlayground
(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}]}
aquilaxPlayground