The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a95efe1
)
Added (length)
author
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 6 Nov 2016 08:53:01 +0000
(21:53 +1300)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 6 Nov 2016 08:53:01 +0000
(21:53 +1300)
scheme-library.scm
patch
|
blob
|
history
diff --git
a/scheme-library.scm
b/scheme-library.scm
index
f95ed65
..
484f500
100644
(file)
--- a/
scheme-library.scm
+++ b/
scheme-library.scm
@@
-13,6
+13,14
@@
(define (cddr l) (cdr (cdr l)))
(define (cadar l) (car (cdr (car l))))
+; Return number of items in list
+(define (length l)
+ (define (iter a count)
+ (if (null? a)
+ count
+ (iter (cdr a) (+ count 1))))
+ (iter l 0))
+
; Join two lists together
(define (join l1 l2)
(if (null? l1)