about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-03 16:28:15 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-03 16:28:15 -0700
commit7ced4e44ddb6e15152eb8bcef9dda68aba53710b (patch)
tree0ffafb03332b72db32c1f65c468734faa7443f9f
parentd986404ff03bca8d87062c0011829b262448876a (diff)
downloadmu-7ced4e44ddb6e15152eb8bcef9dda68aba53710b.tar.gz
alists
-rw-r--r--shell/data.limg13
1 files changed, 13 insertions, 0 deletions
diff --git a/shell/data.limg b/shell/data.limg
index 0c46da98..fcc7a1ba 100644
--- a/shell/data.limg
+++ b/shell/data.limg
@@ -101,6 +101,19 @@
       if (f (car xs))
         (cons (car xs) rest)
         rest])
+    (alist? . [def (alist? x)
+  (and (cons? x)
+       (cons? (car x)))])
+    (assoc . [def (assoc alist key)
+  if (no alist)
+    ()
+    if (key = (caar alist))
+      (car alist)
+      (assoc (cdr alist) key)])
+    (get . [def (get alist key)
+  aif (assoc alist key)
+    (cdr it)
+    ()])
     (++ . [mac (++ var) `(set ,var (,var + 1))])
     (+= . [mac (var += inc)
   `(set ,var (,var + ,inc))])