diff options
author | Kartik Agaram <vc@akkartik.com> | 2021-06-06 19:03:41 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2021-06-06 19:03:41 -0700 |
commit | e941dd505cd7392ac24fd6ad9c848ab2a3dfbe33 (patch) | |
tree | 68b8dc82e473cf93d835838d5db1146755aa518e | |
parent | e962a53f9a7c7ddd439380b2500990c36816c40f (diff) | |
download | mu-e941dd505cd7392ac24fd6ad9c848ab2a3dfbe33.tar.gz |
.
-rw-r--r-- | shell/data.limg | 18 |
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) () |