about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-06-06 19:03:41 -0700
committerKartik Agaram <vc@akkartik.com>2021-06-06 19:03:41 -0700
commite941dd505cd7392ac24fd6ad9c848ab2a3dfbe33 (patch)
tree68b8dc82e473cf93d835838d5db1146755aa518e /shell
parente962a53f9a7c7ddd439380b2500990c36816c40f (diff)
downloadmu-e941dd505cd7392ac24fd6ad9c848ab2a3dfbe33.tar.gz
.
Diffstat (limited to 'shell')
-rw-r--r--shell/data.limg18
1 files changed, 18 insertions, 0 deletions
diff --git a/shell/data.limg b/shell/data.limg
index b3c9ad2d..2457f134 100644
--- a/shell/data.limg
+++ b/shell/data.limg
@@ -51,6 +51,24 @@
     (afn . [(mac (afn params . body)
   `(let self ()
      (set self (fn ,params ,@body))))])
+    (seq . [(def (seq n)
+  ((afn (i)
+     (if (> i n)
+       ()
+       (cons i (self (+ i 1)))))
+   1))])
+    (each . [(mac (each x xs . body)
+  `(walk ,xs (fn (,x) ,@body)))])
+    (walk . [(def (walk xs f)
+  (when xs
+    (f (car xs))
+    (walk (cdr xs) f))) ])
+    (up . [(mac (up var init max . body)
+  `(for ,var ,init (<= ,var ,max) (++ ,var)
+     ,@body))])
+    (down . [(mac (down var init min . body)
+  `(for ,var ,init (>= ,var ,min) (-- ,var)
+     ,@body))])
     (rem . [(def (rem f xs)
   (if (no xs)
     ()