summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/scripting.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/chickadee/scripting.scm b/chickadee/scripting.scm
index d88e422..ff65e86 100644
--- a/chickadee/scripting.scm
+++ b/chickadee/scripting.scm
@@ -22,6 +22,7 @@
#:use-module (chickadee scripting channel)
#:use-module (chickadee scripting script)
#:export (forever
+ repeat
sleep
tween)
#:replace (sleep))
@@ -41,6 +42,13 @@
"Evaluate BODY in an endless loop."
(while #t body ...))
+(define-syntax-rule (repeat n body ...)
+ "Evaluate BODY N times."
+ (let loop ((i 0))
+ (when (< i n)
+ body ...
+ (loop (+ i 1)))))
+
(define (sleep duration)
"Wait DURATION before resuming the current script."
;; Capture the current agenda before suspending the script so that