<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>unfold.lisp</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -40,6 +40,7 @@
                (:file &quot;curry&quot;)
                (:file &quot;vector&quot;)
                (:file &quot;assemble&quot;)
+               (:file &quot;unfold&quot;)
                (:file &quot;range&quot;)
                (:file &quot;prelude&quot;)
                (:file &quot;hash-table&quot;)</diff>
      <filename>incf-cl.asd</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,7 @@
   (:export #:curry
            #:vector+ #:vector- #:vector* #:vector&gt; #:vector= #:vector-zero-p
            #:assemble #:&lt;-
+           #:unfold #:unfold-right
            #:range
            #:break* #:drop #:drop-while #:filter #:flip #:insert #:replicate
            #:span #:split-at #:take #:take-while #:unzip</diff>
      <filename>package.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,8 @@
 ;;; resembling Matlab vector notation).
 
 (defun range (a b &amp;optional c)
+  ;; This could be implemented using unfold too but we do it this way
+  ;; for efficiency.
   (flet ((aux (start step stop)
            (assert (and (&lt;= start stop) (&gt; step 0)))
            (loop for x from start to stop by step collect x)))</diff>
      <filename>range.lisp</filename>
    </modified>
    <modified>
      <diff>@@ -174,6 +174,34 @@
   (is (string= &quot;Hello, world&quot;
                (string-join (list &quot;Hello&quot; &quot;world&quot;) &quot;, &quot;))))
 
+(defun read-lines (stream)
+  (when (streamp stream)
+    (unfold (curry #'eq stream)
+            #'identity
+            (lambda (x)
+              (declare (ignore x))
+              (read-line stream nil stream))
+            (read-line stream nil stream))))
+
+(deftest test-unfold ()
+  (is (eq nil (unfold (constantly t) #'identity #'identity 0)))
+  (is (eq t (doctest :incf-cl :function #'unfold)))
+  (is (equal (range 0 .1 (/ pi 2))
+             (unfold (curry (flip #'&gt;) (/ pi 2))
+                     #'identity
+                     (lambda (x) (+ x 0.1))
+                     0)))
+  (with-input-from-string (stream
+                           &quot;1
+                                     2
+                                     3&quot;)
+    (is (equal (list &quot;1&quot; &quot;2&quot; &quot;3&quot;)
+               (mapcar (curry #'string-trim &quot; #\Tab&quot;)
+                       (read-lines stream))))))
+
+(deftest test-unfold-right ()
+  (is (eq t (doctest :incf-cl :function #'unfold-right))))
+
 (deftest test-doctest ()
   &quot;This is a sample docstring.
 </diff>
      <filename>tests.lisp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>02ff91200a1dc984c471897d6d4f9ab8b677c774</id>
    </parent>
  </parents>
  <author>
    <name>Juan M. Bello Rivas</name>
    <email>jmbr@superadditive.com</email>
  </author>
  <url>http://github.com/jmbr/incf-cl/commit/b87f605079df6cd96abea6a7e748b1f5d06c4083</url>
  <id>b87f605079df6cd96abea6a7e748b1f5d06c4083</id>
  <committed-date>2007-12-14T07:44:59-08:00</committed-date>
  <authored-date>2007-12-14T07:44:59-08:00</authored-date>
  <message>Implemented unfold and unfold-right</message>
  <tree>5a88af2d07f8220c5bf0dcaf19289d9b7590c5b9</tree>
  <committer>
    <name>Juan M. Bello Rivas</name>
    <email>jmbr@superadditive.com</email>
  </committer>
</commit>
