about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-10-11 21:21:31 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-10-11 21:21:31 -0700
commitbb1d5c2cd33cd196becbc39c3f8d287cf5a080bf (patch)
tree5197c56c05a9e62e5a3a965f79168e7c525debe2
parent2308b970661834484c1b59729e5f88b0f4bbcc51 (diff)
downloadmu-bb1d5c2cd33cd196becbc39c3f8d287cf5a080bf.tar.gz
.
-rw-r--r--shell/data.limg12
1 files changed, 12 insertions, 0 deletions
diff --git a/shell/data.limg b/shell/data.limg
index 03aa276d..02a6fd5e 100644
--- a/shell/data.limg
+++ b/shell/data.limg
@@ -122,6 +122,18 @@
      (while ,test
        ,@body
        ,update))])
+    (repeat . [# Ideally we shouldn't have to provide
+# var.
+# But then nested repeats won't work
+# until we use gensyms.
+# And shell doesn't currently support
+# gensyms.
+# By exposing var to caller, it becomes
+# caller's responsibility to use unique
+# vars for each invocation of repeat.
+mac (repeat var n . body)
+  `(for ,var 0 (,var < ,n) (++ ,var)
+     ,@body)])
     (grid . [def (grid m n val)
   ret g (populate n ())
     for i 0 (< i n) ++i