core: Add member.

* src/lib.c (member): New function.
* module/mes/scm.mes (member): Remove.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-07 12:18:50 +02:00
parent 5e9c539f57
commit f33d23bca1
2 changed files with 18 additions and 5 deletions

View file

@ -126,11 +126,6 @@
(define memv memq)
(define (member x lst)
(if (null? lst) #f
(if (equal? x (car lst)) lst
(member x (cdr lst)))))
;;; Lists
(define (make-list n . x)

View file

@ -312,3 +312,21 @@ equal2_p (SCM a, SCM b)
}
return eq_p (a, b);
}
SCM
member (SCM x, SCM a)
{
switch (TYPE (x))
{
case TCHAR:
case TNUMBER:
case TKEYWORD:
case TSYMBOL:
case TSPECIAL:
return memq (x, a);
default:
while (a != cell_nil && equal2_p (x, CAR (a)) != cell_t)
a = CDR (a);
}
return a != cell_nil ? a : cell_f;
}