extracted parse-seed-maps out of seed-maps-processor

main
Inga 🏳‍🌈 11 months ago
parent 4729fdbe40
commit 7ffb594999
  1. 19
      day05-hard/main.scm

@ -445,15 +445,20 @@
flat flat
(map (apply-map-to-state-entry seed-map))))) (map (apply-map-to-state-entry seed-map)))))
(define (seed-maps-processor raw-seed-maps) (define (seed-maps-processor seed-maps)
(compose (list (compose (list
;; for state ;; for state
#!(tee-with-comment "state after applying mapset")!# #!(tee-with-comment "state after applying mapset")!#
((compose (list ((compose (list
;; for list of map lines (within a single map set); should return state-transforming lambda ;; for list of maps (within a single map set); should return state-transforming lambda
compose compose
(map apply-map-to-state) (map apply-map-to-state)))
#!(tee-with-comment "current mapset")!# seed-maps)
swap-state)))
(define parse-seed-maps
(compose (list
;; for list of map lines (within a single map set)
(prepend '(0 4294967295 0)) (prepend '(0 4294967295 0))
(map (compose (list (map (compose (list
;; for map line ;; for map line
@ -465,10 +470,7 @@
(split (is #\space)) (split (is #\space))
string->list string->list
))) )))
#!(tee-with-comment "raw seed maps without prefix")!# cdr)))
cdr))
raw-seed-maps)
swap-state)))
(define parse-initial (define parse-initial
(compose (list (compose (list
@ -487,6 +489,7 @@
(((compose (list (((compose (list
compose compose
(map seed-maps-processor) (map seed-maps-processor)
(map parse-seed-maps)
reverse reverse
(filter is-not-empty) (filter is-not-empty)
(split (is "")))) (split (is ""))))

Loading…
Cancel
Save