From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.bugs Subject: Re: [bug #30070] multiple returns from map Date: Sun, 14 Aug 2011 22:52:29 +0200 Message-ID: References: <20100607-182303.sv74648.31837@savannah.gnu.org> <20110715-104507.sv78157.85748@savannah.gnu.org> <20110812-210321.sv20118.97813@savannah.gnu.org> <87pqk7g3qe.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015177403dc2e034404aa7d532d X-Trace: dough.gmane.org 1313355161 2689 80.91.229.12 (14 Aug 2011 20:52:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 14 Aug 2011 20:52:41 +0000 (UTC) Cc: bug-guile@gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Aug 14 22:52:36 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qshff-0000Ag-IX for guile-bugs@m.gmane.org; Sun, 14 Aug 2011 22:52:35 +0200 Original-Received: from localhost ([::1]:44864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qshff-0007MI-50 for guile-bugs@m.gmane.org; Sun, 14 Aug 2011 16:52:35 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:33544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qshfc-0007MC-Dh for bug-guile@gnu.org; Sun, 14 Aug 2011 16:52:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qshfb-0006G1-2B for bug-guile@gnu.org; Sun, 14 Aug 2011 16:52:32 -0400 Original-Received: from mail-iy0-f175.google.com ([209.85.210.175]:60799) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qshfa-0006Fx-VL for bug-guile@gnu.org; Sun, 14 Aug 2011 16:52:31 -0400 Original-Received: by iyn15 with SMTP id 15so4633847iyn.6 for ; Sun, 14 Aug 2011 13:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=C5Ibz0G9WKvTu0KU6mUxm9F0wU7na04bAPiXPRmazKk=; b=KNDX8yuFWQlp31MIBivBc8G9nFt13PLL6Qjm+sExwEUfekXlWLyCqew0AkvmYHuKQq iSRSfUCxwNIytXORr5omG7i4RivP87l3PLtvotkb7iXuG1ASYm5jR7VGYOQiGrfrQY22 J0zZohwm5hVC5kKgEfNLMZgmCZp/k8viJXKsw= Original-Received: by 10.231.67.141 with SMTP id r13mr3837908ibi.65.1313355150000; Sun, 14 Aug 2011 13:52:30 -0700 (PDT) Original-Received: by 10.231.182.134 with HTTP; Sun, 14 Aug 2011 13:52:29 -0700 (PDT) In-Reply-To: <87pqk7g3qe.fsf@pobox.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.175 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5772 Archived-At: --0015177403dc2e034404aa7d532d Content-Type: text/plain; charset=ISO-8859-1 Interestingly there is another option assuming some magic, Consider: (define (map f L) (clear-recurrent-flag) (let ((ret (let loop ((L L) (R '())) (if (pair? L) (loop (cdr L) (cons (car L) R)) R)))) (got-recurrent? (reverse ret) (reverse! ret)))) /Stefan On Sun, Aug 14, 2011 at 10:03 PM, Andy Wingo wrote: > On Sat 13 Aug 2011 17:56, Stefan Israelsson Tampe > writes: > > > Yes a tail pointer was a mind slip . But I did > > changed the final reverse! to the functional reverse in the srfi-1 > version of map > > and doing that should be enough. > > Yes, however there is a performance penalty. We should probably do that > for R6RS. But long-term, we need a solution that does not impose a > performance penalty. That solution is to map recursively instead of > iteratively. > > Andy > -- > http://wingolog.org/ > --0015177403dc2e034404aa7d532d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Interestingly there is another option assuming some magic,

Consider:=
(define (map f L)
=A0=A0 (clear-recurrent-flag)
=A0=A0 (let ((ret= (let loop ((L L) (R '())) (if (pair? L) (loop (cdr L) (cons (car L) R)= ) R))))
=A0=A0=A0=A0=A0 (got-recurrent?
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (reverse=A0 = ret)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (reverse! ret))))

/Stefan
On Sun, Aug 14, 2011 at 10:03 PM, Andy Wingo <wingo@pobox.com&= gt; wrote:
On Sat 13 Aug 2011 17:56, Stefan Israelsson Tampe <stefan.itampe@gmail.com> writes:

> Yes a tail pointer was a mind slip . But I did
> changed the final reverse! to the functional reverse in the srfi-1 ver= sion of map
> and doing that should be enough.

Yes, however there is a performance penalty. =A0We should probably do= that
for R6RS. =A0But long-term, we need a solution that does not impose a
performance penalty. =A0That solution is to map recursively instead of
iteratively.

Andy
--
http://wingolog.org/=

--0015177403dc2e034404aa7d532d--