Added length built-in.
authorDaniel Kraft <d@domob.eu>
Wed, 29 Jul 2009 11:45:40 +0000 (13:45 +0200)
committerDaniel Kraft <d@domob.eu>
Wed, 29 Jul 2009 11:45:40 +0000 (13:45 +0200)
* module/language/elisp/runtime/function-slot.scm: Add length built-in.
* test-suite/tests/elisp-compiler.test: Test length.

module/language/elisp/runtime/function-slot.scm
test-suite/tests/elisp-compiler.test

index 805f22a..e2838b5 100644 (file)
           ((zero? i) tail)
           (else (iterate (prim 1- i) (prim cdr tail))))))))
 
+(built-in-func length (@ (guile) length))
+
 
 ; Building lists.
 
index e8bb46c..7b87999 100644 (file)
          (equal (nthcdr 1 '(1 2 3)) '(2 3))
          (equal (nthcdr 2 '(1 2 3)) '(3))))
 
+  (pass-if "length"
+    (and (= (length '()) 0)
+         (= (length '(1 2 3 4 5)) 5)
+         (= (length '(1 2 (3 4 (5)) 6)) 4)))
+
   (pass-if "cons, list and make-list"
     (and (equal (cons 1 2) '(1 . 2)) (equal (cons 1 '(2 3)) '(1 2 3))
          (equal (cons 1 '()) '(1))