I added the simple REPEAT clause that's supported by CL's LOOP to PS's pseudo-LOOP:<br><br>(ps (loop repeat 3 do (alert "hi")))<br><br>=><br><br>"for (var _js3691 = 0; _js3691 < 3; _js3691 += 1) {<br>
alert('hi');<br>};"<br><br>Daniel<br><br><br>From 043a85a1f155068af509e05fd32ae2adcfb0f30f Mon Sep 17 00:00:00 2001<br>From: Daniel Gackle <<a href="mailto:danielgackle@gmail.com">danielgackle@gmail.com</a>><br>
Date: Fri, 31 Jul 2009 14:20:15 -0600<br>Subject: [PATCH] Added :REPEAT clauses to PS's LOOP.<br><br>---<br> src/lib/ps-loop.lisp | 7 ++++++-<br> 1 files changed, 6 insertions(+), 1 deletions(-)<br><br>diff --git a/src/lib/ps-loop.lisp b/src/lib/ps-loop.lisp<br>
index c7334fa..38ea78c 100644<br>--- a/src/lib/ps-loop.lisp<br>+++ b/src/lib/ps-loop.lisp<br>@@ -9,7 +9,7 @@<br> (defvar *loop-keywords*<br> '(:for :do :when :unless :initially :finally :first-time :last-time :while :until<br>
:from :to :below :downto :above :by :in :across :on :index := :then :sum :collect<br>- :count :minimize :maximize :into))<br>+ :count :minimize :maximize :into :repeat))<br> <br> (defun normalize-loop-keywords (args)<br>
(mapcar<br>@@ -146,10 +146,15 @@<br> ((:in :across) (for-in var))<br> (:on (for-on var))<br> (otherwise (error "FOR ~s ~s is not valid in PS-LOOP." var term)))))<br>
+ (repeat-clause ()<br>+ (let ((index (ps-gensym)))<br>+ (setf terms (append `(:for ,index :from 0 :below ,(consume)) terms))<br>+ (clause)))<br> (clause ()<br>
(let ((term (consume-atom)))<br> (case term<br> (:for (for-clause))<br>+ (:repeat (repeat-clause))<br> (:while (push `(unless ,(consume) break) body))<br>
(:until (push `(when ,(consume) break) body))<br> (:initially (push (consume-progn) initially))<br>-- <br>1.6.1<br><br><br>