[comp.lang.icon] sets

goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) (07/23/89)

Recently I ran a simple program like this:

  lineset := set()
  while line := !&input do {
    insert(lineset,line)
    }
  every write(!lineset)

I used it to remove duplicate lines from a file
looking like this:

stuffofonesort data data data
stuffofanothersort data data data
stuffofanothersort data data data
stuffofonesort data data data

When I printed everything out, all the lines begin-
ning with stuffofonesort were together; same with
stuffofanothersort.  However, sorting stopped there.
No sorting was done on the data fields (separated
by a space from the first field).  They were listed
in the order in which they were entered into the
set.

This is a neat feature.  By some wild coincidence
this sorting order turned out to be very, very
useful to me.  But why did it turn out that way?
Could someone who understands the implementation
better help?

-Richard

P.S.  The Xenix 386 implementation of Icon is, by
all report, very fast and nice.  I am planning on
snarfing a copy over soon (as soon as I get some
hardware questions nailed down).  Before I get all
involved with it, I wonder:  Has anyone implemented
coexpressions and not told us about it?  I wish I
could say I was competent to write good 386 assem-
bler code, but alas....  If someone else is either
working on this, or else had done it, I'd really
like to know about it.