diff options
| author | Mistivia <i@mistivia.com> | 2024-02-16 11:07:30 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2024-02-16 11:07:30 +0800 |
| commit | e1a5304af2c35ff83819546953309764e24656d4 (patch) | |
| tree | 8992bf2a489e4dc7f6ff3b9661aae5a50d08cab9 /advent-of-code/2023/lib/utils.rkt | |
| parent | a19a1b970e5dd6983be8660ef6e0f5929fb5a149 (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.rkt | 11 |
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 '())) |
