From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: srfi-1 map! Date: Tue, 11 Nov 2003 10:32:52 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87ptfzpwwb.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1068510843 23272 80.91.224.253 (11 Nov 2003 00:34:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Nov 2003 00:34:03 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Nov 11 01:34:01 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AJMTo-0000ib-00 for ; Tue, 11 Nov 2003 01:34:01 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AJNQy-000888-9I for guile-devel@m.gmane.org; Mon, 10 Nov 2003 20:35:08 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AJNQr-00087i-LA for guile-devel@gnu.org; Mon, 10 Nov 2003 20:35:01 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AJNQL-00082w-Qf for guile-devel@gnu.org; Mon, 10 Nov 2003 20:35:00 -0500 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AJNQL-00082E-3j for guile-devel@gnu.org; Mon, 10 Nov 2003 20:34:29 -0500 Original-Received: from mongrel.pacific.net.au (mongrel.pacific.net.au [61.8.0.107]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAB0X3V0000779 for ; Tue, 11 Nov 2003 11:33:03 +1100 Original-Received: from localhost (ppp25.dyn228.pacific.net.au [203.143.228.25]) by mongrel.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAB0VxDJ026698 for ; Tue, 11 Nov 2003 11:32:00 +1100 Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 1AJMSj-0002ot-00; Tue, 11 Nov 2003 10:32:53 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2987 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2987 --=-=-= I've been finding it a bit annoying that map can handle long lists but map! can't. * srfi-1.scm (map!): Define as an alias for map, previous definition was not tail-recursive. --=-=-= Content-Disposition: attachment; filename=srfi-1.scm.mapx.diff --- srfi-1.scm.~1.29.~ 1970-01-01 10:00:01.000000000 +1000 +++ srfi-1.scm 2003-11-11 10:28:35.000000000 +1000 @@ -572,22 +572,8 @@ '() (append! (apply f (map1 car l)) (lp (map1 cdr l))))))) -(define (map! f list1 . rest) - (if (null? rest) - (let lp ((l list1)) - (if (null? l) - '() - (begin - (set-car! l (f (car l))) - (set-cdr! l (lp (cdr l))) - l))) - (let lp ((l (cons list1 rest)) (res list1)) - (if (any1 null? l) - '() - (begin - (set-car! res (apply f (map1 car l))) - (set-cdr! res (lp (map1 cdr l) (cdr res))) - res))))) +;; OPTIMIZE-ME: Re-use cons cells of given list(s) +(define map! map) (define (pair-for-each f clist1 . rest) (if (null? rest) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--