apply concat > mapcat identity

This commit is contained in:
Adam Jeniski 2023-12-03 14:43:52 -05:00
parent bbd5f8818f
commit 57576bd5a4

View File

@ -12,7 +12,7 @@
(map-indexed (fn [col-idx char] (map-indexed (fn [col-idx char]
[[row-idx col-idx] char]) [[row-idx col-idx] char])
line))) line)))
(mapcat identity) (apply concat)
(into {}))) (into {})))
;; produces a list of [row-idx col-idx "num"] ;; produces a list of [row-idx col-idx "num"]
@ -22,7 +22,7 @@
(map-indexed (fn [row matches] (map-indexed (fn [row matches]
(map #(vector row (:start %) (:group %)) (map #(vector row (:start %) (:group %))
matches))) matches)))
(mapcat identity))) (apply concat)))
(defn coords-to-check [row col num-str] (defn coords-to-check [row col num-str]
(for [r [(dec row) row (inc row)] (for [r [(dec row) row (inc row)]
@ -49,7 +49,7 @@
(filter #(= \* (second %))) (filter #(= \* (second %)))
(map #(vector % num-str))))) (map #(vector % num-str)))))
(filter seq) (filter seq)
(mapcat identity) (apply concat)
(map (fn [[[coords] num-str]] [coords num-str])))) (map (fn [[[coords] num-str]] [coords num-str]))))
;; gears is a set of [star-row-idx star-col-idx] ;; gears is a set of [star-row-idx star-col-idx]