List functions
This commit is contained in:
+1
-1
@@ -113,4 +113,4 @@ Spec is of the form (VARIABLE LIST &optional RETURN-FORM)."
|
||||
(princ datum print-char-fun)
|
||||
(terpri print-char-fun))
|
||||
|
||||
(princln (nconc '(1 2) '(4 . 6) '(3 4)))
|
||||
(princln (append '(1 2) '(3 4)))
|
||||
|
||||
+24
-1
@@ -93,7 +93,30 @@ DEFUN(reverse, "reverse", (LispVal * list), "(list)", "") {
|
||||
}
|
||||
|
||||
DEFUN(append, "append", (LispVal * lists), "(&rest lists)", "") {
|
||||
return Qnil;
|
||||
LispVal *out = Qnil;
|
||||
LispVal *end = Qnil;
|
||||
DOTAILS(rest, lists) {
|
||||
LispVal *cur = XCAR(rest);
|
||||
CHECK_LISTP(cur);
|
||||
if (NILP(cur)) {
|
||||
continue;
|
||||
}
|
||||
if (!NILP(XCDR(rest))) {
|
||||
cur = Fcopy_list(cur);
|
||||
}
|
||||
if (NILP(out)) {
|
||||
out = cur;
|
||||
} else {
|
||||
RPLACD(end, cur);
|
||||
}
|
||||
if (!NILP(XCDR(rest))) {
|
||||
end = Flast(cur);
|
||||
if (!NILP(XCDR(end))) {
|
||||
signal_type_error(cur, Qlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
DEFUN(nconc, "nconc", (LispVal * lists), "(&rest lists)", "") {
|
||||
|
||||
Reference in New Issue
Block a user