<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -68,3 +68,9 @@
 (def eval-these (exprs)
   (if (acons exprs)
       (do (eval (car exprs)) (eval-these (cdr exprs)))))
+
+(mac afnwith (withses . body)
+  (let w (pair withses)
+    `((afn ,(map car w) ,@body) ,@(map cadr w))))
+
+</diff>
      <filename>src/arc/lib/bag-of-tricks.arc</filename>
    </modified>
    <modified>
      <diff>@@ -160,8 +160,9 @@
     (= ignore (uniq))
 
     (def unescape-fragment (fragment)
-      (string (accum s
-        ((afn (chs escaping)
+      (string:accum s
+        (afnwith (chs      (coerce fragment 'cons)
+                  escaping nil)
           (iflet ch (car chs)
             (if escaping
                 (do
@@ -176,7 +177,7 @@
                 (case ch
                   #\\ (self (cdr chs) t)
                       (do (s ch)
-                          (self (cdr chs) nil)))))) (coerce fragment 'cons) nil))))
+                          (self (cdr chs) nil))))))))
 
     (def assemble-string (fragments)
       (if no.fragments</diff>
      <filename>src/arc/lib/parser.arc</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@
          (itable (cadr tok)))))
 
 (def delete-from-index (itable remfn)
-  (ontable k v itable
+  (each (k v) itable
     (= itable.k (rem remfn v))))
 
 (assign definers (cdr '(x def mac redef assign defop newsop defweld atdef)))</diff>
      <filename>src/arc/lib/source.arc</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,11 @@
 
 (register-test '(suite &quot;Foundation Tests&quot;
+
+  (&quot;datetime breaks date into calendar components&quot;
+    ((fn (d)
+      (list d.5 d.4 d.3)) (datetime 1203450000))
+    (2008 01 19))
+
   (suite &quot;Strings&quot;
     (&quot;get the length of a string&quot;
       (len &quot;foo-bar-toto&quot;)</diff>
      <filename>src/arc/lib/tests/foundation-test.arc</filename>
    </modified>
    <modified>
      <diff>@@ -49,11 +49,10 @@
                             (trunc (/ (- (ended) started) 1000.0))
                             0))
       (marks      ()    (len marked))
-      (surrounded (p)   ((afn (ns)
+      (surrounded (p)   (afnwith (ns (neighbours p))
                            (if (no ns)       0
                                (mf (car ns)) (+ 1 (self (cdr ns)))
-                                             (self (cdr ns))))
-                         (neighbours p)))
+                                             (self (cdr ns)))))
       (here       ()    `(,cursor-x ,cursor-y))
       (dimension  ()    `(,(+ max-x 1) ,(+ max-y 1)))
       (clear?     (p)   (cleared p))
@@ -61,7 +60,7 @@
       (won?       ()    (is (+ (len cleared) (len mf))
                             (apply * (dimension))))
       (lost?      ()    (catch
-                          (ontable p bomb mf
+                          (each (p bomb) mf
                             (when (and bomb (cleared p))
                               (throw t)))
                           nil))
@@ -87,7 +86,7 @@
                           (redraw this)))))))
 
 (def redraw (mf)
-  (ontable k v mf!cells
+  (each (k v) mf!cells
     (v (if (mf!clear? k)  (if (mf!bomb? k)
                               'exploded
                               'exposed)</diff>
      <filename>src/arc/rainbow/mines.arc</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-(require-lib &quot;rainbow/img&quot;)
+(require-lib &quot;rainbow/img&quot;) 
 
 (attribute script src  opstring)
 (attribute script type opstring)
@@ -87,13 +87,16 @@
                    (clickable span &quot;zoom_out_button&quot; &quot;zoom out&quot;)
                    (text-input zoom0)
                    (clickable span &quot;copy_zoom_button&quot; &quot;copy&quot;))
-              (tag tr
-                   (tag td (pr &quot;frames&quot;))
-                   (tag td (text-input frames))
-                   (tag (td colspan 2) (pr &quot;for animation&quot;))))
-         (tag (input type &quot;submit&quot; value &quot;plot this&quot;))
-         (nbsp)
-         (tag (input type &quot;submit&quot; value &quot;animate (x+iy) -&gt; (x'+iy')&quot; id &quot;animate&quot;))))
+              (row (nbsp)
+                   (nbsp)
+                   (nbsp)
+                   (pr &quot;frames&quot;)
+                   (text-input frames))
+              (row (nbsp)
+                   (tag (input type &quot;submit&quot; value &quot;plot this&quot;))
+                   (nbsp)
+                   (nbsp)
+                   (tag (input type &quot;submit&quot; value &quot;animate&quot; id &quot;animate&quot;))))))
 
 (def spiral-help ()
   (pr &quot;&lt;p&gt;plot values of iterating &lt;code&gt;z &amp;lt;- z&lt;sup&gt;2&lt;/sup&gt; + c&lt;/code&gt; where c is &lt;code&gt;x+iy&lt;/code&gt;&lt;/p&gt;&quot;))
@@ -188,7 +191,7 @@
          z 0+0i
          n 0
          repeats 0)
-    (while (and (small z) (&lt; n 100000) (&lt; repeats 1000))
+    (while (and (small z) (&lt; n 20000) (&lt; repeats 1000))
       (++ n)
       (assign z (+ c (* z z)))
       (if (apply p!plot (complex-parts z)) (++ repeats)
@@ -230,7 +233,10 @@
       (zap [+ _ stepy] y))))
 
 (def animation-info ()
-  (tag (span id &quot;animinfo&quot;) (nbsp)))
+  (tag (span id &quot;animinfo&quot;) (nbsp))
+  (br)
+  (tag (input id &quot;fps&quot; value &quot;20&quot;))
+  (pr &quot;fps&quot;))
 
 (defop animate req
   (spiral-params req
@@ -252,6 +258,7 @@
 ; http://localhost:8085/spiral?x=-0.092&amp;x0=-0.0318807&amp;y=0.649&amp;y0=0.6418998&amp;ox=-0.18278875&amp;oy=0.6933475&amp;nc=0.0001&amp;zoom=1.966080000000001&amp;zoom0=1&amp;frames=20
 ; http://localhost:8085/animate?x=0.0743&amp;x0=-0.1257&amp;y=0.6464&amp;y0=0.8464&amp;ox=0.0011&amp;oy=-0.0023&amp;nc=0.01&amp;zoom=1.5&amp;zoom0=0.5&amp;frames=400
 ; http://localhost:8085/animate?x=-0.1&amp;x0=-0.31&amp;y=0.6264&amp;y0=0.6264&amp;ox=-0.1014390625&amp;oy=0.7252390625&amp;nc=0.08&amp;zoom=2.5&amp;zoom0=2.5&amp;frames=1000
+; http://localhost:8085/animate?x=-0.314&amp;x0=-0.317&amp;y=0.6264&amp;y0=0.6264&amp;ox=-0.3&amp;oy=0.45&amp;nc=0.08&amp;zoom=1.3&amp;zoom0=1.3&amp;frames=2000
 
 ;; old coordinates:
 ; http://localhost:8080/animate?x=-0.39&amp;y=-0.47&amp;x0=-0.55&amp;y0=-0.63&amp;ox=-0.94625&amp;oy=-0.77609375&amp;nc=0.0008&amp;zoom=1.2&amp;frames=600</diff>
      <filename>src/arc/rainbow/spiral.arc</filename>
    </modified>
    <modified>
      <diff>@@ -11,10 +11,5 @@
       ((fn (a-bobo)
         (a-bobo 3)
       ) (annotate 'bobo 23))
-    69))
-
-  (&quot;datetbl breaks date into calendar components&quot;
-    ((fn (d)
-      (list (d 'year) (d 'month) (d 'day))) (datetbl 1203450000))
-    (2008 01 19))))
+    69))))
 </diff>
      <filename>src/arc/rainbow/tests/anarki-compatibility-test.arc</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,7 @@
   (assign delay* 0.5 score* 0 paused* nil)
   (assign universe (table) cell-updates* (table))
   (new-shape)
-  (ontable k v universe-cells*
+  (each (k v) universe-cells*
     (repaint-cell k nil))
   (update-score))
 
@@ -50,12 +50,12 @@
 
 (def shape (colour cells)
   (= colours (cons colour colours))
-  ((afn (info)
+  (afnwith (info cells)
     (if info
       (let (rotation row col) (car info)
         (= shape-rotations.colour rotation)
         (set (shape-info (shape-cell-key colour rotation row col)))
-        (self (cdr info))))) cells))
+        (self (cdr info))))))
 
 (shape 'red    '((0 0 1) (0 1 1) (0 2 1) (0 3 1)
                  (1 1 0) (1 1 1) (1 1 2) (1 1 3)))
@@ -194,7 +194,7 @@
     (set-cell colour (+ row falling!y) (+ col falling!x))))
 
 (def update-updates (cells-to-update)
-  (ontable k v cells-to-update
+  (each (k v) cells-to-update
     (repaint-cell k (if (is v 'none) nil v))))
 
 (def repaint-cell (k colour)</diff>
      <filename>src/arc/rainbow/tetris.arc</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 body, td {
   font-family:Verdana, sans-serif;
   font-size:7pt;
+  color:white;
+  background:black;
 }
 
 .clickable {</diff>
      <filename>src/arc/static/spiral.css</filename>
    </modified>
    <modified>
      <diff>@@ -56,6 +56,14 @@
     };
   }
 
+  function getFPS() {
+    var fps = parseFloat($(&quot;fps&quot;).value);
+    if (isNaN(fps) || fps &gt; 100) {
+      fps = 100;
+    }
+    return fps;
+  }
+
   var vars = [&quot;x&quot;, &quot;y&quot;, &quot;x0&quot;, &quot;y0&quot;, &quot;zoom&quot;, &quot;zoom0&quot;, &quot;ox&quot;, &quot;oy&quot;];
 
   for (var i = 0; i &lt; vars.length; i++) {
@@ -138,6 +146,12 @@
       var n = 0;
 
       function step() {
+        var fps = getFPS();
+        if (fps &lt;= 0) {
+          setInterval(step, 50);
+          return;
+        }
+
         var loaded = 0;
         var img = $(&quot;anim_&quot; + n);
         img.style.display = 'none';
@@ -166,13 +180,16 @@
           img = $(&quot;anim_&quot; + n);
         }
 
-        $(&quot;animinfo&quot;).innerHTML = &quot;frame &quot; + n + &quot;,&lt;br/&gt;&quot; + img.alt + &quot;&lt;br/&gt;(loaded &quot; + loaded + &quot; of &quot; + ld + &quot;)&quot;;
+        fps = getFPS();
+        $(&quot;animinfo&quot;).innerHTML = &quot;frame &quot; + n + &quot;,&lt;br/&gt;&quot; + img.alt + &quot;&lt;br/&gt;(loaded &quot; + loaded + &quot; of &quot; + ld + &quot;)&lt;br/&gt;&quot; + fps + &quot;fps&quot;;
         if (img.complete) {
           img.style.display = '';
         }
+
+        setTimeout(step, 1000/fps);
       }
 
-      setInterval(step, 50);
+      step();
     }
 
   };</diff>
      <filename>src/arc/static/spiral.js</filename>
    </modified>
    <modified>
      <diff>@@ -23,18 +23,20 @@ public class SystemFunctions {
       public ArcObject invoke(Pair args) {
         return Rational.make(System.currentTimeMillis() / 1000);
       }
-    }, new Builtin(&quot;datetbl&quot;) {
+    }, new Builtin(&quot;datetime&quot;) {
       public ArcObject invoke(Pair args) {
         Calendar c = new GregorianCalendar();
-        c.setTime(new Date(1000 * Rational.cast(args.car(), this).toInt()));
-        Hash hash = new Hash();
-        hash.sref(Symbol.make(&quot;year&quot;), Rational.make(c.get(Calendar.YEAR)));
-        hash.sref(Symbol.make(&quot;month&quot;), Rational.make(c.get(Calendar.MONTH)));
-        hash.sref(Symbol.make(&quot;day&quot;), Rational.make(c.get(Calendar.DAY_OF_MONTH)));
-        hash.sref(Symbol.make(&quot;hour&quot;), Rational.make(c.get(Calendar.HOUR_OF_DAY)));
-        hash.sref(Symbol.make(&quot;minute&quot;), Rational.make(c.get(Calendar.MINUTE)));
-        hash.sref(Symbol.make(&quot;second&quot;), Rational.make(c.get(Calendar.SECOND)));
-        return hash;
+        if (!args.isNil()) {
+          c.setTime(new Date(1000 * Rational.cast(args.car(), this).toInt()));
+        }
+        return Pair.buildFrom(
+                Rational.make(c.get(Calendar.SECOND)),
+                Rational.make(c.get(Calendar.MINUTE)),
+                Rational.make(c.get(Calendar.HOUR_OF_DAY)),
+                Rational.make(c.get(Calendar.DAY_OF_MONTH)),
+                Rational.make(c.get(Calendar.MONTH)),
+                Rational.make(c.get(Calendar.YEAR))
+        );
       }
     }, new Builtin(&quot;current-process-milliseconds&quot;) {
       public ArcObject invoke(Pair args) {
@@ -61,6 +63,10 @@ public class SystemFunctions {
       public ArcObject invoke(Pair args)  {
         return Symbol.make(System.getProperty(&quot;os.name&quot;).replaceAll(&quot; &quot;, &quot;&quot;).toLowerCase());
       }
+    }, new Builtin(&quot;declare&quot;) {
+      public ArcObject invoke(Pair args)  {
+        return NIL;
+      }
     }, new Builtin(&quot;quit&quot;) {
       public ArcObject invoke(Pair args) {
         System.exit(0);</diff>
      <filename>src/java/rainbow/functions/SystemFunctions.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ad9e3d0ec94749876408672536ffc6cabfd75acc</id>
    </parent>
  </parents>
  <author>
    <name>conan</name>
    <email>conan@london.local</email>
  </author>
  <url>http://github.com/conanite/rainbow/commit/727525530513bd793baf397de0a9acfdf729e14e</url>
  <id>727525530513bd793baf397de0a9acfdf729e14e</id>
  <committed-date>2009-07-05T14:34:14-07:00</committed-date>
  <authored-date>2009-07-05T14:34:14-07:00</authored-date>
  <message> - afnwith in lib/bag-of-tricks
 - use each instead of ontable
 - delete datetbl (ex anarki), implement datetime (arc3)
 - implement null 'declare - does nothing &amp; returns nil</message>
  <tree>e1004b1472440f2a4bec8d31d88346868fa897a2</tree>
  <committer>
    <name>conan</name>
    <email>conan@london.local</email>
  </committer>
</commit>
