From eede3242a5d2e58bfbe9b1255b5c08143a4c9a34 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 4 Nov 2013 20:52:57 -0500 Subject: [PATCH] add memq/assq --- piclib/built-in.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 5f35f6a7..78633727 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -74,6 +74,20 @@ (define (list-set! 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) (if (null? obj) obj