mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
Added length built-in.
* module/language/elisp/runtime/function-slot.scm: Add length built-in. * test-suite/tests/elisp-compiler.test: Test length.
This commit is contained in:
parent
a6a5cf03d4
commit
c2c7c27755
2 changed files with 7 additions and 0 deletions
|
@ -179,6 +179,8 @@
|
|||
((zero? i) tail)
|
||||
(else (iterate (prim 1- i) (prim cdr tail))))))))
|
||||
|
||||
(built-in-func length (@ (guile) length))
|
||||
|
||||
|
||||
; Building lists.
|
||||
|
||||
|
|
|
@ -553,6 +553,11 @@
|
|||
(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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue