aboutsummaryrefslogtreecommitdiff
path: root/2024/aoc-utils.scm
diff options
context:
space:
mode:
authorMatias Linares <matias@deprecated.org>2024-12-10 08:56:26 -0300
committerMatias Linares <matias@deprecated.org>2024-12-10 08:56:32 -0300
commit28d6d95fcbe14494857d80da7ea02b5926d85a15 (patch)
tree714e8d3339f11fc283be2f31cdcdfb89deeecd8f /2024/aoc-utils.scm
parent1a81d370510a01b482aae8033704d1a0523d11b7 (diff)
downloadadvent-of-code-28d6d95fcbe14494857d80da7ea02b5926d85a15.tar.gz
Add day 05 - 2024HEADmaster
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>