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 circular-list Date: Sat, 20 Mar 2004 08:11:27 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87fzc4h4hc.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1079734521 10756 80.91.224.253 (19 Mar 2004 22:15:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 19 Mar 2004 22:15:21 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Mar 19 23:15:12 2004 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 1B4SGm-00074z-00 for ; Fri, 19 Mar 2004 23:15:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B4SED-0000uw-18 for guile-devel@m.gmane.org; Fri, 19 Mar 2004 17:12:33 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B4SE1-0000rb-5d for guile-devel@gnu.org; Fri, 19 Mar 2004 17:12:21 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B4SDP-0000ja-MJ for guile-devel@gnu.org; Fri, 19 Mar 2004 17:12:14 -0500 Original-Received: from [61.8.0.85] (helo=mailout2.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B4SDO-0000jI-Sm for guile-devel@gnu.org; Fri, 19 Mar 2004 17:11:43 -0500 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout2.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i2JMBb5v018879 for ; Sat, 20 Mar 2004 09:11:37 +1100 Original-Received: from localhost (ppp220.dyn11.pacific.net.au [61.8.11.220]) by mailproxy1.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i2JMBabq006287 for ; Sat, 20 Mar 2004 09:11:36 +1100 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1B4SDA-0000e4-00; Sat, 20 Mar 2004 08:11:28 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.4 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:3530 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3530 --=-=-= * srfi-1.scm (circular-list): Rewrite using set-cdr!, no need to copy parameter list. --=-=-= Content-Disposition: inline; filename=srfi-1.scm.circular-list.diff --- srfi-1.scm.~1.31.~ 2003-12-03 07:14:46.000000000 +1000 +++ srfi-1.scm 2004-03-18 14:59:56.000000000 +1000 @@ -1,6 +1,6 @@ ;;; srfi-1.scm --- List Library -;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +;; Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -247,16 +247,10 @@ acc (lp (- n 1) (cons (init-proc (- n 1)) acc))))) -(define (circular-list elt1 . rest) - (let ((start (cons elt1 '()))) - (let lp ((r rest) (p start)) - (if (null? r) - (begin - (set-cdr! p start) - start) - (begin - (set-cdr! p (cons (car r) '())) - (lp (cdr r) (cdr p))))))) +(define (circular-list . lst) + (if (not (null? lst)) + (set-cdr! (last-pair lst) lst)) + lst) (define (iota count . rest) (check-arg-type non-negative-integer? count "iota") --=-=-= 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 --=-=-=--