unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* doco srfi-1 delete, delete-duplicates
@ 2003-05-12 23:50 Kevin Ryde
  2003-05-13  2:26 ` Rob Browning
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Ryde @ 2003-05-12 23:50 UTC (permalink / 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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-12 23:50 doco srfi-1 delete, delete-duplicates Kevin Ryde
@ 2003-05-13  2:26 ` Rob Browning
  2003-05-13  9:25   ` tomas
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Browning @ 2003-05-13  2:26 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> 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.

Same temptation here.  Perhaps cmp, or comparison, or cmp-func...

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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13  2:26 ` Rob Browning
@ 2003-05-13  9:25   ` tomas
  2003-05-13 11:52     ` Mikael Djurfeldt
  0 siblings, 1 reply; 9+ messages in thread
From: tomas @ 2003-05-13  9:25 UTC (permalink / raw)
  Cc: guile-devel

On Mon, May 12, 2003 at 09:26:58PM -0500, Rob Browning wrote:
> Kevin Ryde <user42@zip.com.au> writes:
> 
> > 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.
> 
> Same temptation here.  Perhaps cmp, or comparison, or cmp-func...

Cmp is good (since, as the example shows, it's not just about some
kind of equality). Pred or predicate might be a candidate as well.
(but I like cmp best).

Regards
-- tomas


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13  9:25   ` tomas
@ 2003-05-13 11:52     ` Mikael Djurfeldt
  2003-05-13 13:31       ` tomas
  2003-05-15 23:29       ` Kevin Ryde
  0 siblings, 2 replies; 9+ messages in thread
From: Mikael Djurfeldt @ 2003-05-13 11:52 UTC (permalink / raw)
  Cc: Rob Browning

tomas@fabula.de writes:

> On Mon, May 12, 2003 at 09:26:58PM -0500, Rob Browning wrote:
>> Kevin Ryde <user42@zip.com.au> writes:
>> 
>> > 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.
>> 
>> Same temptation here.  Perhaps cmp, or comparison, or cmp-func...
>
> Cmp is good (since, as the example shows, it's not just about some
> kind of equality). Pred or predicate might be a candidate as well.
> (but I like cmp best).

...and I think "cmp" is cryptic, arbitrary and ugly, while "=" is
beautiful, and I don't think there is any risk of confusion.  I think
the original "=" is good taste.  :-)

And if you guys anyway want to change it, please 1. give it a readable
name (e.g. equal-predicate?), and 2. make sure to put a `?' after it
(if it is a textual name) to indicate that it is a predicate.

M


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13 11:52     ` Mikael Djurfeldt
@ 2003-05-13 13:31       ` tomas
  2003-05-13 18:40         ` Mikael Djurfeldt
  2003-05-15 23:29       ` Kevin Ryde
  1 sibling, 1 reply; 9+ messages in thread
From: tomas @ 2003-05-13 13:31 UTC (permalink / raw)
  Cc: Rob Browning

On Tue, May 13, 2003 at 01:52:03PM +0200, Mikael Djurfeldt wrote:
> tomas@fabula.de writes:
> 
[...]
> > Cmp is good [...]

> ...and I think "cmp" is cryptic, arbitrary and ugly, while "=" is
> beautiful, and I don't think there is any risk of confusion.  I think
> the original "=" is good taste.  :-)

Hehe, design taste makes always for good discussions :-)

> And if you guys anyway want to change it, please 1. give it a readable
> name (e.g. equal-predicate?), and 2. make sure to put a `?' after it
> (if it is a textual name) to indicate that it is a predicate.

I was for cmp (or similar) since it's not really about equality
(in fact, the example shows a meaningful use of < for it). I
thoroughly agree with you on the ?, but I think equal-predicate?
would be misleading (since it's not about any kind of equality
here -- the < used in the example isn't even an equivalence relation).

So how would be `compare?'

regards
-- tomas


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13 13:31       ` tomas
@ 2003-05-13 18:40         ` Mikael Djurfeldt
  2003-05-14  8:15           ` tomas
  0 siblings, 1 reply; 9+ messages in thread
From: Mikael Djurfeldt @ 2003-05-13 18:40 UTC (permalink / raw)
  Cc: Rob Browning

tomas@fabula.de writes:

> On Tue, May 13, 2003 at 01:52:03PM +0200, Mikael Djurfeldt wrote:
>> tomas@fabula.de writes:
>> 
> [...]
>> > Cmp is good [...]
>
>> ...and I think "cmp" is cryptic, arbitrary and ugly, while "=" is
>> beautiful, and I don't think there is any risk of confusion.  I think
>> the original "=" is good taste.  :-)
>
> Hehe, design taste makes always for good discussions :-)

:-)

>> And if you guys anyway want to change it, please 1. give it a readable
>> name (e.g. equal-predicate?), and 2. make sure to put a `?' after it
>> (if it is a textual name) to indicate that it is a predicate.
>
> I was for cmp (or similar) since it's not really about equality
> (in fact, the example shows a meaningful use of < for it). I
> thoroughly agree with you on the ?, but I think equal-predicate?
> would be misleading (since it's not about any kind of equality
> here -- the < used in the example isn't even an equivalence relation).
>
> So how would be `compare?'

That's fine with me.  (I guess there is an alternative naming scheme
along `delete?' etc.)

Finding names must be one of the most difficult problems in software
engineering---really.

M


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13 18:40         ` Mikael Djurfeldt
@ 2003-05-14  8:15           ` tomas
  0 siblings, 0 replies; 9+ messages in thread
From: tomas @ 2003-05-14  8:15 UTC (permalink / raw)
  Cc: tomas

On Tue, May 13, 2003 at 08:40:46PM +0200, Mikael Djurfeldt wrote:

[...]

> That's fine with me.  (I guess there is an alternative naming scheme
> along `delete?' etc.)
> 
> Finding names must be one of the most difficult problems in software
> engineering---really.

I agree. And one of the appeals of this list to me is that such
things actually get discussed.

[insert some semi-philosophical rambling about least-surprise,
data compression in the brain and knowing how a function will
be called like without ever looking it upin the docs]

Regards
-- tomas


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-13 11:52     ` Mikael Djurfeldt
  2003-05-13 13:31       ` tomas
@ 2003-05-15 23:29       ` Kevin Ryde
  2003-05-15 23:47         ` Paul Jarc
  1 sibling, 1 reply; 9+ messages in thread
From: Kevin Ryde @ 2003-05-15 23:29 UTC (permalink / raw)


Mikael Djurfeldt <djurfeldt@nada.kth.se> writes:
>
> ...and I think "cmp" is cryptic, arbitrary and ugly,

And suggests to me a positive, negative, or zero to give an ordering.
Too much C programming I guess ...

> And if you guys anyway want to change it, please 1. give it a readable
> name (e.g. equal-predicate?), and 2. make sure to put a `?' after it
> (if it is a textual name) to indicate that it is a predicate.

Is a predicate normally thought of as a function taking one argument?
I suppose it can be used more loosely than that.

"equal-proc?" might be a possibility.


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


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

* Re: doco srfi-1 delete, delete-duplicates
  2003-05-15 23:29       ` Kevin Ryde
@ 2003-05-15 23:47         ` Paul Jarc
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Jarc @ 2003-05-15 23:47 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> wrote:
> Is a predicate normally thought of as a function taking one argument?

Many predicates are one-place predicates, but some (such as <) have
greater arity.  Generally, a predicate is a function that returns a
boolean value.

How about "deletable?"?


paul


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


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

end of thread, other threads:[~2003-05-15 23:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-12 23:50 doco srfi-1 delete, delete-duplicates Kevin Ryde
2003-05-13  2:26 ` 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

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