Add basic lexenv support
This commit is contained in:
23
src/list.c
23
src/list.c
@ -60,3 +60,26 @@ DEFUN(listp, "listp", (LispVal * obj), "(obj)", "") {
|
||||
DEFUN(list, "list", (LispVal * args), "(&rest args)", "") {
|
||||
return args;
|
||||
}
|
||||
|
||||
DEFUN(plist_put, "plist-put", (LispVal * plist, LispVal *prop, LispVal *value),
|
||||
"(plist prop value)", "") {
|
||||
CHECK_LISTP(plist);
|
||||
DOTAILS(rest, plist) {
|
||||
if (EQ(XCAR(rest), prop)) {
|
||||
RPLACA(XCDR(rest), value);
|
||||
return plist;
|
||||
}
|
||||
}
|
||||
return CONS(prop, CONS(value, plist));
|
||||
}
|
||||
|
||||
DEFUN(plist_get, "plist-get", (LispVal * plist, LispVal *prop, LispVal *def),
|
||||
"(plist prop &optional default)", "") {
|
||||
CHECK_LISTP(plist);
|
||||
DOTAILS(rest, plist) {
|
||||
if (EQ(XCAR(rest), prop)) {
|
||||
return SECOND(rest);
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user