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: doco srfi-1 delete, delete-duplicates Date: Tue, 13 May 2003 09:50:12 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87fznj2097.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1052783801 28203 80.91.224.249 (12 May 2003 23:56:41 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 12 May 2003 23:56:41 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue May 13 01:56:37 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 19FN8k-0007Fr-00 for ; Tue, 13 May 2003 01:55:30 +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 19FN7s-0004OM-05 for guile-devel@m.gmane.org; Mon, 12 May 2003 19:54:36 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 19FN6E-0003Qr-00 for guile-devel@gnu.org; Mon, 12 May 2003 19:52:54 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 19FN5B-0002kA-00 for guile-devel@gnu.org; Mon, 12 May 2003 19:51:50 -0400 Original-Received: from snoopy.pacific.net.au ([61.8.0.36]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19FN3n-0002AT-00 for guile-devel@gnu.org; Mon, 12 May 2003 19:50:23 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) h4CNoKPc013313 for ; Tue, 13 May 2003 09:50:20 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h4CNoKQg013691 for ; Tue, 13 May 2003 09:50:20 +1000 (EST) Original-Received: from localhost (ppp112.dyn228.pacific.net.au [203.143.228.112]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h4CNoHYZ022741 for ; Tue, 13 May 2003 09:50:18 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19FN3c-0002qp-00; Tue, 13 May 2003 09:50:12 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (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:2344 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2344 Some new words to propose for srfi-1 delete and delete-duplicates. The behaviour described is per the srfi-1 spec, the words are by me. Conditions like the arg order of the calls and the common tail in the returns are new, insofar as they weren't described before, but presumably no-one would expect guile to deviate from the spec, so in that sense there's no change. I was sorely tempted to change the "=" formal parameter to something like "eproc", to avoid any chance of it being confused with the core "=" procedure. But if that's to be done then I suppose it should be throughout the chapter, not just in one node. Deleting -------- - Scheme Procedure: delete x lst [=] - Scheme Procedure: delete! x lst [=] Return a list containing the elements of LST but with those equal to X deleted. The returned elements will be in the same order as they were in LST. Equality is determined by the = predicate, or `equal?' if not given. An equality call is made just once for each element, but the order in which the calls are made on the elements is unspecified. The equality calls are always `(= x elem)', ie. the given X is first. This means for instance elements greater than 5 can be deleted with `(delete 5 lst <)'. `delete' does not modify LST, but the return might share a common tail with LST. `delete!' may modify the structure of LST to construct its return. - Scheme Procedure: delete-duplicates lst [=] - Scheme Procedure: delete-duplicates! lst [=] Return a list containing the elements of LST but without duplicates. When elements are equal, only the first in LST is retained. Equal elements can be anywhere in LST, they don't have to be adjacent. The returned list will have the retained elements in the same order as they were in LST. Equality is determined by the = predicate, or `equal?' if not given. Calls `(= x y)' are made with element X being before Y in LST. A call is made at most once for each combination, but the sequence of the calls across the elements is unspecified. `delete-duplicates' does not modify LST, but the return might share a common tail with LST. `delete-duplicates!' may modify the structure of LST to construct its return. In the worst case, this is an O(N^2) algorithm because it must check each element against all those preceding it. For long lists it is more efficient to sort and then compare only adjacent elements. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel