From xemacs-m  Mon Jun 16 08:48:09 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id IAA17033
	for <xemacs-beta@xemacs.org>; Mon, 16 Jun 1997 08:48:07 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id PAA22126; Mon, 16 Jun 1997 15:48:01 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: `mapvector' a subr
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 16 Jun 1997 15:47:59 +0200
Message-ID: <kig67veek1c.fsf@jagor.srce.hr>
Lines: 59
X-Mailer: Gnus v5.4.52/XEmacs 20.3(beta6)

I think `mapvector' is a good candidate to make into a subr.  Because
of dynamic scoping, the Lisp implementation is especially ugly.  It's
less lines of code in C than in Lisp (sic!)

--- src/fns.c.orig	Mon Jun 16 14:58:08 1997
+++ src/fns.c	Mon Jun 16 15:05:03 1997
@@ -3271,6 +3271,21 @@
   return Flist (len, args);
 }
 
+DEFUN ("mapvector", Fmapvector, 2, 2, 0, /*
+Apply FUNCTION to each element of SEQUENCE, making a vector of the results.
+The result is a vector of the same length as SEQUENCE.
+SEQUENCE may be a list, a vector or a string.
+*/
+       (fn, seq))
+{
+  int len = XINT (Flength (seq));
+  Lisp_Object *args = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+
+  mapcar1 (len, args, fn, seq);
+
+  return Fvector (len, args);
+}
+
 DEFUN ("mapc-internal", Fmapc_internal, 2, 2, 0, /*
 Apply FUNCTION to each element of SEQUENCE.
 SEQUENCE may be a list, a vector, a bit vector, or a string.
--- lisp/prim/subr.el.orig	Mon Jun 16 15:03:27 1997
+++ lisp/prim/subr.el	Mon Jun 16 15:03:32 1997
@@ -238,21 +238,6 @@
 (define-function 'rplaca 'setcar)
 (define-function 'rplacd 'setcdr)
 
-;; XEmacs
-(defun mapvector (__function __seq)
-  "Apply FUNCTION to each element of SEQ, making a vector of the results.
-The result is a vector of the same length as SEQ.
-SEQ may be a list, a vector or a string."
-  (let* ((len (length __seq))
-	 (vec (make-vector len 'nil))
-	 (i 0))
-    (while (< i len)
-      (aset vec i (funcall __function (cond ((listp __seq)
-					     (nth i __seq))
-					    (t (aref __seq i)))))
-      (setq i (+ i 1)))
-    vec))
-
 ;;;; String functions.
 
 ;; XEmacs


-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Unspeakable horrors from outer space paralyze the living and
resurrect the dead!

