From: Kevin Ryde <user42@zip.com.au>
Subject: doco srfi-1 delete, delete-duplicates
Date: Tue, 13 May 2003 09:50:12 +1000 [thread overview]
Message-ID: <87fznj2097.fsf@zip.com.au> (raw)
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
next reply other threads:[~2003-05-12 23:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-12 23:50 Kevin Ryde [this message]
2003-05-13 2:26 ` doco srfi-1 delete, delete-duplicates Rob Browning
2003-05-13 9:25 ` tomas
2003-05-13 11:52 ` Mikael Djurfeldt
2003-05-13 13:31 ` tomas
2003-05-13 18:40 ` Mikael Djurfeldt
2003-05-14 8:15 ` tomas
2003-05-15 23:29 ` Kevin Ryde
2003-05-15 23:47 ` Paul Jarc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fznj2097.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).