From xemacs-m  Mon Jun 16 09:01:16 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 JAA17303
	for <xemacs-beta@xemacs.org>; Mon, 16 Jun 1997 09:01:14 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id QAA24352; Mon, 16 Jun 1997 16:01:10 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: `mapvector' a subr
References: <kig67veek1c.fsf@jagor.srce.hr>
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 16:01:10 +0200
In-Reply-To: Hrvoje Niksic's message of 16 Jun 1997 15:47:59 +0200
Message-ID: <kigk9jur6jd.fsf@jagor.srce.hr>
Lines: 71
X-Mailer: Gnus v5.4.52/XEmacs 20.3(beta6)

Hrvoje Niksic <hniksic@srce.hr> writes:

> --- src/fns.c.orig	Mon Jun 16 14:58:08 1997
> +++ src/fns.c	Mon Jun 16 15:05:03 1997
[...]

Oops, wrong patch!  Here is the correct one (with the defsubr):

--- src/fns.c.orig	Mon Jun 16 14:58:08 1997
+++ src/fns.c	Mon Jun 16 15:25:02 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.
@@ -3465,6 +3480,7 @@
   DEFSUBR (Ffillarray);
   DEFSUBR (Fnconc);
   DEFSUBR (Fmapcar);
+  DEFSUBR (Fmapvector);
   DEFSUBR (Fmapc_internal);
   DEFSUBR (Fmapconcat);
   DEFSUBR (Fload_average);
--- 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
--------------------------------+--------------------------------
"Silence!" cries Freydag. "I did not call thee in for a consultation!" 
"They are my innards! I will not have them misread by a poseur!"

