Fix gc bug and add condition classes
This commit is contained in:
+21
@@ -1,5 +1,7 @@
|
||||
#include "list.h"
|
||||
|
||||
#include "function.h"
|
||||
|
||||
intptr_t list_length(LispVal *list) {
|
||||
assert(LISTP(list));
|
||||
LispVal *tortise = list;
|
||||
@@ -61,6 +63,25 @@ DEFUN(list, "list", (LispVal * args), "(&rest args)", "") {
|
||||
return args;
|
||||
}
|
||||
|
||||
DEFUN(member, "member", (LispVal * elt, LispVal *list, LispVal *pred),
|
||||
"(elt list &optional pred)", "") {
|
||||
if (NILP(pred) || pred == Qeq) {
|
||||
// fast case
|
||||
DOTAILS(rest, list) {
|
||||
if (elt == XCAR(rest)) {
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DOTAILS(rest, list) {
|
||||
if (CALL(pred, elt, XCAR(rest))) {
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
DEFUN(plist_put, "plist-put", (LispVal * plist, LispVal *prop, LispVal *value),
|
||||
"(plist prop value)", "") {
|
||||
CHECK_LISTP(plist);
|
||||
|
||||
Reference in New Issue
Block a user