add memq/memv.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-11 11:05:17 +02:00
parent 1621cfd284
commit 2e1e307f13
3 changed files with 24 additions and 1 deletions

3
TODO
View file

@ -19,7 +19,8 @@ v length
v list
v list->vector
v make-vector
memv
v memq
v memv
v string
v string-append
v string?

View file

@ -23,6 +23,12 @@
(define (list . rest) rest)
(define (vector . rest) (list->vector rest))
(define assv assq)
(define (memq x lst)
(cond ((null? lst) #f)
((eq? x (car lst)) lst)
(#t (memq x (cdr lst)))))
(define memv memq)
(define (+ x y) (- x (- 0 y)))

View file

@ -222,4 +222,20 @@
(display v)
(newline)
(display "memq a: ")
(display (memq 'a '(a b c)))
(newline)
(display "memq b: ")
(display (memq 'b '(a b c)))
(newline)
(display "memq c: ")
(display (memq 'c '(a b c)))
(newline)
(display "memq d: ")
(display (memq 'd '(a b c)))
(newline)
'()