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

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

@ -445,31 +445,33 @@
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)
(prepend '(0 4294967295 0))
(map (compose (list
;; for map line
create-map
(map (compose (list
;; for number in map line
string->number
list->string)))
(split (is #\space))
string->list
)))
#!(tee-with-comment "raw seed maps without prefix")!#
cdr))
raw-seed-maps)
swap-state))) swap-state)))
(define parse-seed-maps
(compose (list
;; for list of map lines (within a single map set)
(prepend '(0 4294967295 0))
(map (compose (list
;; for map line
create-map
(map (compose (list
;; for number in map line
string->number
list->string)))
(split (is #\space))
string->list
)))
cdr)))
(define parse-initial (define parse-initial
(compose (list (compose (list
(map (compose (list (map (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