Author: yamakenz
Date: Tue Jul 10 03:40:05 2007
New Revision: 4682

Modified:
   trunk/scm/util.scm
   trunk/test/test-util.scm

Log:
* scm/util.scm
  - (truncate-list): Simplify with SRFI-1 'take'
  - (list-head): Rewrite as an alias to SRFI-1 'take'
* test/test-util.scm
  - Update the "passed revision" comment


Modified: trunk/scm/util.scm
==============================================================================
--- trunk/scm/util.scm  (original)
+++ trunk/scm/util.scm  Tue Jul 10 03:40:05 2007
@@ -89,19 +89,12 @@
   (lambda (lst str)
     (member str lst)))
 
+;; should be obsoleted by 'take'
 (define truncate-list
   (lambda (lst n)
-    (if (or (< (length lst)
-              n)
-           (< n 0))
-       #f
-       (let self ((lst lst)
-                  (n n))
-         (if (or (= n 0)
-                 (null? lst))
-             ()
-             (cons (car lst)
-                   (self (cdr lst) (- n 1))))))))
+    (guard (err
+           (else #f))
+      (take lst n))))
 
 ;; procedural 'or' for use with 'apply'
 ;; e.g. (apply proc-or boolean-lst)
@@ -123,12 +116,8 @@
        (and (car xs)
             (apply proc-and (cdr xs))))))
 
-(define list-head
-  (lambda (lst n)
-    (if (= n 0)  ;; required due to bug #642
-       ()
-       (or (truncate-list lst n)
-           (error "out of range in list-head")))))
+;; should be obsoleted by 'take'
+(define list-head take)
 
 ;; TODO: write test
 (define sublist

Modified: trunk/test/test-util.scm
==============================================================================
--- trunk/test/test-util.scm    (original)
+++ trunk/test/test-util.scm    Tue Jul 10 03:40:05 2007
@@ -29,7 +29,7 @@
 ;;; SUCH DAMAGE.
 ;;;;
 
-;; These tests are passed at revision 4680 (new repository)
+;; These tests are passed at revision 4682 (new repository)
 
 (use test.unit)
 

Reply via email to