JanetDocsPlaygroundI'm feeling luckyGitHub sign in

group-by



    function
    boot.janet on line 1520, column 1

    (group-by f ind)

    Group elements of `ind` by a function `f` and put the results into 
    a table. The keys of the table are the distinct return values of 
    `f`, and the values are arrays of all elements of `ind` that are 
    equal to that value.


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