|
|
|
|
|
by glogla
4565 days ago
|
|
You can make that somewhat more close to the correct computation, you don't need to sort the lists, you just need min values. (->> [2 3 4 7 5 3 11 12 7]
(group-by even?)
vals
(map #(apply min %)))</pre>
However, operation like this can be made much more readable if you actually use variables like this: (defn min-even-odd [xs]
(let [evens (filter even? xs)
odds (filter odd? xs)]
(list (apply min evens) (apply min odds))))
(min-even-odd [2 3 4 7 5 3 11 12 7])
Which is a bit longer, but I think it makes more sense. |
|