diff options
Diffstat (limited to 'shell')
-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) () |