aboutsummaryrefslogtreecommitdiff
path: root/advent-of-code/2023/lib/utils.rkt
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2024-02-16 11:07:30 +0800
committerMistivia <i@mistivia.com>2024-02-16 11:07:30 +0800
commite1a5304af2c35ff83819546953309764e24656d4 (patch)
tree8992bf2a489e4dc7f6ff3b9661aae5a50d08cab9 /advent-of-code/2023/lib/utils.rkt
parenta19a1b970e5dd6983be8660ef6e0f5929fb5a149 (diff)
refactor from c to racket
Diffstat (limited to 'advent-of-code/2023/lib/utils.rkt')
-rw-r--r--advent-of-code/2023/lib/utils.rkt11
1 files changed, 9 insertions, 2 deletions
diff --git a/advent-of-code/2023/lib/utils.rkt b/advent-of-code/2023/lib/utils.rkt
index 946bb86..40c6f6b 100644
--- a/advent-of-code/2023/lib/utils.rkt
+++ b/advent-of-code/2023/lib/utils.rkt
@@ -1,7 +1,14 @@
-#lang racket
+#lang racket/base
(provide get-lines
- enumerate)
+ enumerate
+ repeat)
+
+(define (repeat n e)
+ (let loop ((i 0) (ret '()))
+ (if (>= i n)
+ ret
+ (loop (+ 1 i) (cons e ret)))))
(define (get-lines fp)
(let loop ((lines '()))