I added the simple REPEAT clause that's supported by CL's LOOP to PS's pseudo-LOOP:

(ps (loop repeat 3 do (alert "hi")))

=>

"for (var _js3691 = 0; _js3691 < 3; _js3691 += 1) {
    alert('hi');
};"

Daniel


From 043a85a1f155068af509e05fd32ae2adcfb0f30f Mon Sep 17 00:00:00 2001
From: Daniel Gackle <danielgackle@gmail.com>
Date: Fri, 31 Jul 2009 14:20:15 -0600
Subject: [PATCH] Added :REPEAT clauses to PS's LOOP.

---
 src/lib/ps-loop.lisp |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/lib/ps-loop.lisp b/src/lib/ps-loop.lisp
index c7334fa..38ea78c 100644
--- a/src/lib/ps-loop.lisp
+++ b/src/lib/ps-loop.lisp
@@ -9,7 +9,7 @@
 (defvar *loop-keywords*
   '(:for :do :when :unless :initially :finally :first-time :last-time :while :until
     :from :to :below :downto :above :by :in :across :on :index := :then :sum :collect
-    :count :minimize :maximize :into))
+    :count :minimize :maximize :into :repeat))
 
 (defun normalize-loop-keywords (args)
   (mapcar
@@ -146,10 +146,15 @@
                      ((:in :across) (for-in var))
                      (:on (for-on var))
                      (otherwise (error "FOR ~s ~s is not valid in PS-LOOP." var term)))))
+               (repeat-clause ()
+                 (let ((index (ps-gensym)))
+                   (setf terms (append `(:for ,index :from 0 :below ,(consume)) terms))
+                   (clause)))
                (clause ()
                  (let ((term (consume-atom)))
                    (case term
                      (:for (for-clause))
+                     (:repeat (repeat-clause))
                      (:while (push `(unless ,(consume) break) body))
                      (:until (push `(when ,(consume) break) body))
                      (:initially (push (consume-progn) initially))
--
1.6.1