This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-09
Channels
- # babashka (176)
- # beginners (26)
- # cider (1)
- # cljsrn (3)
- # clojure (60)
- # clojure-australia (3)
- # clojure-europe (8)
- # clojure-uk (3)
- # clojurescript (1)
- # code-reviews (4)
- # community-development (3)
- # cursive (6)
- # depstar (1)
- # emacs (11)
- # figwheel (3)
- # helix (13)
- # integrant (2)
- # jackdaw (1)
- # kaocha (1)
- # leiningen (3)
- # luminus (2)
- # malli (4)
- # music (1)
- # nrepl (2)
- # off-topic (1)
- # practicalli (3)
- # reitit (3)
- # shadow-cljs (16)
- # slack-help (14)
- # sql (13)
- # vim (12)
Another solution for the socks (using frequencies, a bit higher level, avoiding explicit reduce):
(->>
[1 2 1 2 1 3 2]
(frequencies)
(map
(fn [[sock-color cnt]]
;determine if we have an odd or even number of socks for each color
(let [cnt' (if (odd? cnt) (dec cnt) cnt)]
;number of pairs of socks for a color
(/ cnt' 2))))
;total of all pairs
(apply +))