From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.devel Subject: Re: srfi-1 take and drop Date: Thu, 08 May 2003 11:35:10 -0500 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <874r45s8g1.fsf@raven.i.defaultvalue.org> References: <87y91lt29u.fsf@zip.com.au> <8765oozwta.fsf@raven.i.defaultvalue.org> <873cjsltsx.fsf@zip.com.au> <87issoydv3.fsf@raven.i.defaultvalue.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052411758 22951 80.91.224.249 (8 May 2003 16:35:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 8 May 2003 16:35:58 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu May 08 18:35:57 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19DoNA-0005y0-00 for ; Thu, 08 May 2003 18:35:56 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19DoNv-00032E-08 for guile-devel@m.gmane.org; Thu, 08 May 2003 12:36:43 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19DoNW-0002ZS-00 for guile-devel@gnu.org; Thu, 08 May 2003 12:36:18 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19DoNN-00026T-00 for guile-devel@gnu.org; Thu, 08 May 2003 12:36:11 -0400 Original-Received: from dsl093-098-016.wdc1.dsl.speakeasy.net ([66.93.98.16] helo=defaultvalue.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19DoMQ-0001Mk-00 for guile-devel@gnu.org; Thu, 08 May 2003 12:35:10 -0400 Original-Received: from raven.i.defaultvalue.org (raven.i.defaultvalue.org [192.168.1.7]) by defaultvalue.org (Postfix) with ESMTP id 6881541D1; Thu, 8 May 2003 11:35:10 -0500 (CDT) Original-Received: by raven.i.defaultvalue.org (Postfix, from userid 1000) id 4FA0A2150F7; Thu, 8 May 2003 11:35:10 -0500 (CDT) Original-To: Kevin Ryde In-Reply-To: (Paul Jarc's message of "Thu, 08 May 2003 12:12:11 -0400") User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2293 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2293 prj@po.cwru.edu (Paul Jarc) writes: > Rob Browning wrote: >> Yep, I have a "take" I haven't committed yet that avoids both stack >> growth and reverse! by tracking the end pair... > > Are you using (ice-9 q)? It seems to be the right tool for that job. Nope. Didn't even know that was there. I had just done this as a first pass: (define (take lst k) ;; avoid a reverse! or stack growth -- easy on the cache, ;; hard on the eyes... (cond ((zero? k) '()) ((negative? k) (error "negative count in call to take.")) (else (let ((result (cons (car lst) '()))) (let lp ((n (- k 1)) (rest (cdr lst)) (end-pair result)) (if (zero? n) result (let ((new-end (cons (car rest) '()))) (set-cdr! end-pair new-end) (lp (- n 1) (cdr rest) new-end)))))))) though thanks for pointing out (ice-9 q). That might be a better idea... -- Rob Browning rlb @defaultvalue.org, @linuxdevel.com, and @debian.org Previously @cs.utexas.edu GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel