From 7ffb594999d8a4a7f9d7c09bfe9d6c4922bbc653 Mon Sep 17 00:00:00 2001 From: Inga Date: Thu, 7 Dec 2023 16:19:43 +0000 Subject: [PATCH] extracted parse-seed-maps out of seed-maps-processor --- day05-hard/main.scm | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/day05-hard/main.scm b/day05-hard/main.scm index 9a60576..1d54d71 100755 --- a/day05-hard/main.scm +++ b/day05-hard/main.scm @@ -445,31 +445,33 @@ flat (map (apply-map-to-state-entry seed-map))))) -(define (seed-maps-processor raw-seed-maps) +(define (seed-maps-processor seed-maps) (compose (list ;; for state #!(tee-with-comment "state after applying mapset")!# ((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 - (map apply-map-to-state) - #!(tee-with-comment "current mapset")!# - (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) + (map apply-map-to-state))) + seed-maps) 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 (compose (list (map (compose (list @@ -487,6 +489,7 @@ (((compose (list compose (map seed-maps-processor) + (map parse-seed-maps) reverse (filter is-not-empty) (split (is ""))))