unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfi-1 circular-list
@ 2004-03-19 22:11 Kevin Ryde
  2004-03-19 22:24 ` Paul Jarc
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2004-03-19 22:11 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 103 bytes --]

        * srfi-1.scm (circular-list): Rewrite using set-cdr!, no need to copy
        parameter list.


[-- Attachment #2: srfi-1.scm.circular-list.diff --]
[-- Type: text/plain, Size: 956 bytes --]

--- 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")

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-19 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-19 22:11 srfi-1 circular-list Kevin Ryde
2004-03-19 22:24 ` Paul Jarc
2004-03-19 22:32   ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).