Fork me on GitHub
#clojure-italy
<
2021-02-11
>
skuro09:02:52

'giorno. una domanda di stile, come la vedete mixare threading macros?

(-> lots-of-maps
    (->> (filter beautiful-things)
         (sort-by :very-important-key))
    first
    :actual-important-key
    (or meaningful-default))

reborg09:02:41

nay :thumbsdown: 😬

reborg09:02:28

quando proprio ho dovuto, ho usato (as->)

👍 4
skuro09:02:53

vero, meno esoterico

reborg09:02:43

Curious facts:

(as-> {:x "15.1" :y "84.2"} {:keys [x y] :as point}
  (update point :x #(Double/valueOf %))
  (update point :y #(Double/valueOf %))
  (assoc point :sum (+ x y))
  (assoc point :keys (keys point)))
;; {:x 15.1, :y 84.2, :sum 99.3, :keys (:x :y :sum)}

reborg09:02:12

1. supporto per il destructuring 2. :sum dimostra che x e y sono stati sia processati che ri-destructurati