home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0963.lha
/
SIOD
/
scm
/
count-atom.scm
< prev
next >
Wrap
Text File
|
1999-12-31
|
646b
|
18 lines
(define (c-atom l)
(define (count-a l)
(do ((count 0)
(pila (make-pila)))
((and (atom? l) (empty-pila? pila))
(set! count (+ count 1)) count)
(cond ((atom? l) (set! count (+ count 1))
(set! l (top pila))
(pop! pila))
(else (push! (car l) pila)
(set! l (cdr l))))))
(count-a l))
(define (count-atom l)
(if (atom? l)
1
(+ (count-atom (car l)) (count-atom (cdr l)))))