add memq/assq

This commit is contained in:
Yuichi Nishiwaki 2013-11-04 20:52:57 -05:00
parent 856d655830
commit eede3242a5
1 changed files with 14 additions and 0 deletions

View File

@ -74,6 +74,20 @@
(define (list-set! list k obj) (define (list-set! list k obj)
(set-car! (list-tail list k) obj)) (set-car! (list-tail list k) obj))
(define (memq obj list)
(if (null? list)
#f
(if (eq? obj (car list))
list
(memq obj (cdr list)))))
(define (assq obj list)
(if (null? list)
#f
(if (eq? obj (caar list))
(car list)
(assq obj (cdr list)))))
(define (list-copy obj) (define (list-copy obj)
(if (null? obj) (if (null? obj)
obj obj