<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,3 @@
-
 FibSequence = Sequence with(
   initialize: method(
     @index = 0
@@ -25,6 +24,10 @@ fib = method(&quot;Returns a sequence that generates all the fibonacci numbers&quot;,
   FibSequence mimic
 )
 
+fib2 = method(
+  fn(a, b, [b, a + b]) iterate(0, 1) mapped(first)
+)
+
 ; find the index of the first fibonacci number larger than a thousand
 (fib indexed(from: 1) takeWhile(second &lt; 1000) last first + 1) println
 fib indexed(from: 1) droppedWhile(second &lt; 1000) first first println</diff>
      <filename>examples/misc/lastFib.ik</filename>
    </modified>
    <modified>
      <diff>@@ -40,3 +40,18 @@ cell(:LexicalBlock) complement = method(
   if(cell?(:activatable) &amp;&amp; activatable,
     fnx(arg, !(cell(:outsideSelf) call(arg))),
     fn(arg, !(cell(:outsideSelf) call(arg)))))
+
+Sequence Iterate = Sequence mimic do(
+  next? = true
+  next = method(
+    v = @currentValue
+    @currentValue = @ cell(:code) call(*v)
+    v
+  )
+)
+
+cell(:LexicalBlock) iterate = method(
+  &quot;Returns an infinite sequence that will in turn yield args, self(args), self(self(args)), etc&quot;,
+  +args,
+  Sequence Iterate with(currentValue: args, code: self)
+)</diff>
      <filename>src/builtin/H10_lexicalBlock.ik</filename>
    </modified>
    <modified>
      <diff>@@ -245,6 +245,30 @@ describe(LexicalBlock,
     )
   )
 
+  describe(&quot;iterate&quot;,
+    it(&quot;should return a sequence&quot;,
+      fn() iterate should mimic(Sequence)
+    )
+
+    it(&quot;should be possible to define a sequence of fibonacci&quot;,
+      fibseq = fn(a, b, [b, a + b]) iterate(0, 1) mapped(first)
+      fibseq next should == 0
+      fibseq next should == 1
+      fibseq next should == 1
+      fibseq next should == 2
+      fibseq next should == 3
+      fibseq next should == 5
+      fibseq next should == 8
+      fibseq next should == 13
+      fibseq next should == 21
+      fibseq next should == 34
+      fibseq next should == 55
+      fibseq next should == 89
+      fibseq next should == 144
+      fibseq next should == 233
+    )
+  )
+
   it(&quot;should report arity failures with regular arguments&quot;,
     noargs = fnx(nil)
     onearg = fnx(x, nil)</diff>
      <filename>test/fn_spec.ik</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>185391fb22028c44a25ef9b61fea1bcc5c13ab2d</id>
    </parent>
  </parents>
  <author>
    <name>Ola Bini</name>
    <email>ola.bini@gmail.com</email>
  </author>
  <url>http://github.com/olabini/ioke/commit/00f4e8955a42ce7d38fa3913bd905bfcbebcee38</url>
  <id>00f4e8955a42ce7d38fa3913bd905bfcbebcee38</id>
  <committed-date>2009-11-06T06:53:27-08:00</committed-date>
  <authored-date>2009-11-06T06:53:27-08:00</authored-date>
  <message>Add support for iterate on LexicalBlock</message>
  <tree>81f6a6b482e3d3deafe3323f3f09e310a25ee9d0</tree>
  <committer>
    <name>Ola Bini</name>
    <email>ola.bini@gmail.com</email>
  </committer>
</commit>
