Change string->list to be iterative.
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 2 Mar 1994 16:48:59 +0000 (16:48 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Wed, 2 Mar 1994 16:48:59 +0000 (16:48 +0000)
v7/src/runtime/string.scm

index 97b1680062856deef7b1dbd5d15d6c58ec1f00dc..14252412d9bac5ba156a2ca0eb2a1636e404ed3b 100644 (file)
@@ -1,8 +1,8 @@
 #| -*-Scheme-*-
 
-$Id: string.scm,v 14.9 1993/10/13 07:40:50 cph Exp $
+$Id: string.scm,v 14.10 1994/03/02 16:48:59 gjr Exp $
 
-Copyright (c) 1988-93 Massachusetts Institute of Technology
+Copyright (c) 1988-1994 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -203,11 +203,13 @@ MIT in each case. |#
   (substring->list string 0 (string-length string)))
 
 (define (substring->list string start end)
-  (let loop ((index start))
+  (let loop ((index start)
+            (accum '()))
     (if (fix:< index end)
-       (cons (string-ref string index)
-             (loop (fix:+ index 1)))
-       '())))
+       (loop (fix:+ index 1)
+             (cons (string-ref string index)
+                   accum))
+       (reverse! accum))))
 
 (define (string-copy string)
   (let ((size (string-length string)))