clojure-italy

🇮🇹
skuro 2021-02-11T09:15:52.032Z

'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))

reborg 2021-02-11T09:16:41.032400Z

nay :thumbsdown: 😬

reborg 2021-02-11T09:19:28.033200Z

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

👍 1
skuro 2021-02-11T09:19:53.033500Z

vero, meno esoterico

skuro 2021-02-11T09:21:01.033700Z

'azie

reborg 2021-02-11T09:24:43.034300Z

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)}

reborg 2021-02-11T09:27:12.035500Z

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