[uim-commit] r139 - trunk/uim
tkng@freedesktop.org
tkng@freedesktop.org
Thu Jan 6 02:55:32 PST 2005
Author: tkng
Date: 2005-01-06 02:54:26 -0800 (Thu, 06 Jan 2005)
New Revision: 139
Modified:
trunk/uim/slib.c
Log:
* uim/slib.c: Mapcar3 was implemented (It's used from custom.scm)
-(mapcar3): New function.
Modified: trunk/uim/slib.c
===================================================================
--- trunk/uim/slib.c 2005-01-06 10:54:22 UTC (rev 138)
+++ trunk/uim/slib.c 2005-01-06 10:54:26 UTC (rev 139)
@@ -4049,6 +4049,22 @@
}
static LISP
+mapcar3 (LISP fcn, LISP in1, LISP in2, LISP in3)
+{
+ LISP res, ptr, l1, l2, l3;
+ if (NULLP (in1) || NULLP (in2) || NULLP (in3))
+ return (NIL);
+ res = ptr = cons (lapply (fcn, cons (car (in1), cons (car (in2), cons (car (in3), NIL)))), NIL);
+
+ for (l1 = cdr (in1), l2 = cdr (in2), l3 = cdr(in3);
+ CONSP (l1) && CONSP (l2) && CONSP(l3);
+ l1 = CDR (l1), l2 = CDR (l2), l3 = CDR (l3))
+ ptr = CDR (ptr) = cons (lapply (fcn, cons (CDR (l1), cons (CDR (l2), cons (CDR (l3), NIL)))), CDR (ptr));
+ // ptr = CDR (ptr) = cons (funcall3 (fcn, CAR (l1), CAR (l2), CAR (l3)),
+ return (res);
+}
+
+static LISP
llength (LISP obj)
{
return (intcons (nlength (obj)));
@@ -4058,12 +4074,15 @@
mapcar (LISP l)
{
LISP fcn = car (l);
+
switch (get_c_int (llength (l)))
{
case 2:
return (mapcar1 (fcn, car (cdr (l))));
case 3:
return (mapcar2 (fcn, car (cdr (l)), car (cdr (cdr (l)))));
+ case 4:
+ return (mapcar3 (fcn, car (cdr (l)), car (cdr (cdr (l))), car (cdr (cdr (cdr (l))))));
default:
return (my_err ("mapcar case not handled", l));
}
More information about the Uim-commit
mailing list