summaryrefslogtreecommitdiffstats
path: root/utils.scm
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-22 21:58:10 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-22 21:58:10 +0300
commite3b21ffd6b88008fd1cc3599a0f816773dc11f9d (patch)
tree6843abb968954cce59e43ebf606bda2ab39b2692 /utils.scm
parentd369f1411c8cf0a07686ed944c8f9f98521129fd (diff)
Refactor whole thing to use in-memory DB as source of truth
Diffstat (limited to 'utils.scm')
-rw-r--r--utils.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils.scm b/utils.scm
index a7f7b17..ab14b22 100644
--- a/utils.scm
+++ b/utils.scm
@@ -45,4 +45,25 @@
(match (assoc key alist)
[#f #f]
[pair (cdr pair)]))
+
+ (define (lookup key alist)
+ (if (not alist)
+ #f
+ (assocdr key alist)))
+
+ (define (filter pred xs)
+ (if (null? xs)
+ xs
+ (if (pred (car xs))
+ (cons (car xs) (filter pred (cdr xs)))
+ (filter pred (cdr xs)))))
+
+ (define (flatten1 as)
+ (foldl append '() as))
+
+ (define (flatmap f xs)
+ (flatten1 (map f xs)))
+
+ (define (falsy? x) (not x))
+ (define (truthy? x) (not (falsy? x)))
)