aboutsummaryrefslogtreecommitdiff
path: root/2024/aoc-utils.scm
diff options
context:
space:
mode:
Diffstat (limited to '2024/aoc-utils.scm')
-rw-r--r--2024/aoc-utils.scm5
1 files changed, 5 insertions, 0 deletions
diff --git a/2024/aoc-utils.scm b/2024/aoc-utils.scm
index 9f22c47..99e086a 100644
--- a/2024/aoc-utils.scm
+++ b/2024/aoc-utils.scm
@@ -8,6 +8,7 @@
file->str
file->matrix
lines->number-list
+ element-index
<matrix>
matrix
@@ -49,6 +50,10 @@
(set! retval (cons i retval)))
retval))
+(define (element-index e lst)
+ (cond [(eqv? e (car lst)) 0]
+ [else (+ (element-index e (cdr lst)) 1)]))
+
;; Matrix utilities
(define-record-type <matrix>