Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7287

Re: reliably sort?

From DrMajorBob <btreat1@austin.rr.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: reliably sort?
Date 2011-12-17 07:45 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jchh9u$idr$1@smc.vnet.net> (permalink)
References <jca06e$a35$1@smc.vnet.net> <201112150956.EAA23025@smc.vnet.net>

Show all headers | View raw


> Result of a Union is a set. Hence one can not talk about
> a set being sorted.  The result is not a set then, but a
> sequence, but the result of a Union should be a set.

a) But Union results ARE sorted. Don't pretend they're not:

Union[RandomInteger[{1, 10}, 20]]

{1, 2, 3, 5, 6, 7, 8, 9}

b) Here are two examples you might not have considered:

Union[f[a, b, a]]

f[a, b]

Union[f[a, b, a], f[c, a]]

f[a, b, c]

No sets there... and not even lists.

c) At school, when he talked about sets, the MATH teacher was not talking  
about computer languages.

d) Generally, we have lists and the functions that act on them. If lists  
have no duplicates, call them sets if you WANT to, but they don't act like  
sets unless you use functions that treat them like sets. For instance,  
does Joining sets give sets???

Join[{a, b, c}, {a}]

{a, b, c, a}

Oops, no.

e) Union, Intersection, and Complement may be the only built-in functions  
that eliminate duplicates in creating outputs... and they don't have to  
have "sets" (lists without duplicates) as their arguments.

Union[List[a, b, a], List[c, a]]

{a, b, c}

f) Union, Intersection, and Complement are not implemented to take  
advantage of the special properties of sets. Union, for instance, Joins  
lists and THEN deletes duplicates. Set theoretic packages exist that do it  
differently, so that duplicates are not created in the first place.

g) Hence, I'll repeat that Mathematica has no "sets". (As distributed.)

Bobby

On Fri, 16 Dec 2011 04:49:18 -0600, Nasser M. Abbasi <nma@12000.org> wrote:

> On 12/15/2011 2:44 PM, DrMajorBob wrote:
>> Michael,
>>
>> Sorry, but no. Union always sorts.
>>
>> Bobby
>>
>
> You mean Mathematica's Union[] always sorts, right? Because
> at school the teacher kept telling us that a set has no
> implied order between its elements. It is just a collection
> of elements. But a sequence has an order.
>
> Result of a Union is a set. Hence one can not talk about
> a set being sorted.  The result is not a set then, but a
> sequence, but the result of a Union should be a set.
>
> --Nasser
>
>
>


-- 
DrMajorBob@yahoo.com

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Does Union[] reliably sort? Michael Stern <nycstern@gmail.com> - 2011-12-14 11:10 +0000
  Re: Does Union[] reliably sort? David Bailey <dave@removedbailey.co.uk> - 2011-12-15 10:03 +0000
  Re: Does Union[] reliably sort? "Nasser M. Abbasi" <nma@12000.org> - 2011-12-15 10:07 +0000
  Re: reliably sort? DrMajorBob <btreat1@austin.rr.com> - 2011-12-16 11:00 +0000
  Re: reliably sort? "Nasser M. Abbasi" <nma@12000.org> - 2011-12-16 11:01 +0000
    Re: reliably sort? David Bailey <dave@removedbailey.co.uk> - 2011-12-18 09:39 +0000
  Re: reliably sort? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2011-12-16 11:09 +0000
  Re: reliably sort? DrMajorBob <btreat1@austin.rr.com> - 2011-12-17 07:45 +0000
  Re: Does Union[] reliably sort? markholtuk <markholtuk@googlemail.com> - 2011-12-17 07:40 +0000
  Re: reliably sort? DrMajorBob <btreat1@austin.rr.com> - 2011-12-17 07:45 +0000
  Re: reliably sort? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2011-12-17 07:47 +0000
  Re: reliably sort? DrMajorBob <btreat1@austin.rr.com> - 2011-12-17 07:52 +0000
  R: Re: reliably sort? "Sir Bob Knight" <sir.bob.knight@gmail.com> - 2011-12-18 09:36 +0000
  Re: Does Union[] reliably sort? Szabolcs <szhorvat@gmail.com> - 2011-12-20 08:08 +0000

csiph-web