Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29438 > unrolled thread
| Started by | Matheus Suffi <matheus.suffi40@gmail.com> |
|---|---|
| First post | 2016-01-25 04:45 -0800 |
| Last post | 2016-02-05 10:51 +0000 |
| Articles | 20 on this page of 55 — 13 participants |
Back to article view | Back to comp.lang.javascript
passing a set of numbers to a function Matheus Suffi <matheus.suffi40@gmail.com> - 2016-01-25 04:45 -0800
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-01-25 10:51 -0300
Re: passing a set of numbers to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-29 03:57 +0100
Re: passing a set of numbers to a function Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-01-28 23:19 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-29 10:09 +0000
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-29 10:20 +0000
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-29 12:23 +0000
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-29 14:50 +0000
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-29 16:11 +0000
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-30 10:10 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-29 08:35 -0800
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-30 10:34 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-30 18:53 -0800
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-31 14:50 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-31 09:56 -0800
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-01 11:02 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-01 18:10 -0800
Re: passing a set of numbers to a function Gene Wirchenko <genew@telus.net> - 2016-01-29 09:38 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-01-29 20:17 +0000
Re: passing a set of numbers to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-29 20:08 +0100
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-01-29 10:32 -0300
Re: passing a set of numbers to a function "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-01-29 14:53 +0100
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-29 06:26 -0800
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-01-29 14:19 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-29 08:38 -0800
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-01-29 13:54 -0300
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-29 10:11 -0800
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-01-29 15:38 -0300
Re: passing a set of numbers to a function Anders Wegge Keller <wegge@geostat.dk> - 2016-01-29 20:13 +0100
Re: passing a set of numbers to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-29 20:46 +0100
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-01-29 16:59 -0300
Re: passing a set of numbers to a function Erwin Moller <erwinmollerusenet@xs4all.nl> - 2016-02-12 12:03 +0100
Re: passing a set of numbers to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-02 11:18 +0100
Re: passing a set of numbers to a function Aleksandro <aleksandro@gmx.com> - 2016-02-02 12:31 -0300
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-04 10:42 +0000
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-04 15:38 +0000
Re: passing a set of numbers to a function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-04 17:33 +0100
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-04 16:19 -0800
Re: passing a set of numbers to a function Stefan Weiss <krewecherl@gmail.com> - 2016-02-05 14:06 +0100
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 05:45 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 14:34 +0000
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 15:42 +0000
Re: passing a set of numbers to a function Stefan Weiss <krewecherl@gmail.com> - 2016-02-05 16:04 +0100
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 10:48 -0800
Re: passing a set of numbers to a function Stefan Weiss <krewecherl@gmail.com> - 2016-02-06 04:50 +0100
Re: passing a set of numbers to a function "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-06 10:05 -0800
Re: passing a set of numbers to a function Stefan Weiss <krewecherl@gmail.com> - 2016-02-06 23:30 +0100
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-06 17:32 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 14:13 +0000
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 17:15 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 05:19 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-05 13:43 +0000
Re: passing a set of numbers to a function Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 06:08 -0800
Re: passing a set of numbers to a function Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-02-04 20:25 +0000
Re: passing a set of numbers to a function John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-05 10:51 +0000
Page 1 of 3 [1] 2 3 Next page →
| From | Matheus Suffi <matheus.suffi40@gmail.com> |
|---|---|
| Date | 2016-01-25 04:45 -0800 |
| Subject | passing a set of numbers to a function |
| Message-ID | <19679ed0-c594-4f7e-817c-a72bd5c10411@googlegroups.com> |
I'm in trouble , I need to send a set of numbers to a function , for example: ' 01599874425 ' . however, when the set of numbers is sent to a function, if the first character is 0, it is deleted . I do not want that to happen ,is there a javascript function or conversion to not let that happen ?
[toc] | [next] | [standalone]
| From | Aleksandro <aleksandro@gmx.com> |
|---|---|
| Date | 2016-01-25 10:51 -0300 |
| Message-ID | <n85939$l92$1@dont-email.me> |
| In reply to | #29438 |
On 25/01/16 09:45, Matheus Suffi wrote: > I'm in trouble , I need to send a set of numbers to a function , for example: ' 01599874425 ' . > however, when the set of numbers is sent to a function, if the first character is 0, it is deleted . > I do not want that to happen ,is there a javascript function or conversion to not let that happen ? As in any scripting language, pass it as a string.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-01-29 03:57 +0100 |
| Message-ID | <7925147.1Px1IdcSyd@PointedEars.de> |
| In reply to | #29438 |
Matheus Suffi wrote: > I'm in trouble , I need to send a set of numbers to a function , for > example: ' 01599874425 ' . That is _not_ a set of numbers; it is, at best, a set of (decimal) digits making up *one* number. > however, when the set of numbers is sent to a function, if the first > character is 0, it is deleted . No, if as posted it most certainly is not. Either you have a strange idea of what it means to "send" something "to a function" (in proper language, you _pass_ a _value_ as an _argument_ to a function) or something in the function code lets the leading zero disappear from the passed value. Nobody can tell for sure until you post both the expression in which you call the function, and the function code (passing numbers as strings just for the sake of it is a bad idea; do not listen to wannabes). You did not even say why you want to do this. (If this is homework, do your own homework. We can assist you if you are stuck, but it is rather unlikely that we do your homework for you.) > I do not want that to happen ,is there a javascript function or conversion > to not let that happen ? 1. There is no “javascript”, see the ECMAScript Support Matrix (URI below). 2. <http://www.catb.org/esr/faqs/smart-questions.html> 3. In English, punctuation is usually not preceded by whitespace. You would be well-advised to post in an easily readable way because otherwise busy, knowledgable people tend to skip postings that are not easily readable. See also the FAQ (URI below). -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2016-01-28 23:19 -0800 |
| Message-ID | <ce08cad8-2934-4870-a3ac-71e831a0f59d@googlegroups.com> |
| In reply to | #29466 |
In a galaxy far far away, Thomas 'Pointed Ears' Lahn prattled: > Matheus Suffi wrote: > > > I'm in trouble , I need to send a set of numbers to a function , for > > example: ' 01599874425 ' . > > That is _not_ a set of numbers; it is, at best, a set of (decimal) digits > making up *one* number. Matheus was just giving an example. No need for bragging about your knowledge in Set Theory. Once again, you're missing the point. > (If this is homework, do your own > homework. We can assist you if you are stuck, > but it is rather unlikely > that we do your homework for you.) By "We", Thomas meant "We, the supreme pedantic assholes in the Usenet,", not the c.l.js group. > > > I do not want that to happen ,is there a javascript function or conversion > > to not let that happen ? > > 1. There is no "javascript", see the ECMAScript Support Matrix (URI below). "Pointy Ears" comes again with his usual annoying BS. There is no "PointedEars". > > 2. <http://www.catb.org/esr/faqs/smart-questions.html> > > 3. In English, punctuation is usually not preceded by whitespace. You would > be well-advised to post in an easily readable way because otherwise busy, > knowledgable people tend to skip postings that are not easily readable. Good. Now the "busy" German troll is lecturing English to foreigners. <spam> > See also the FAQ (URI below). </spam>
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-01-29 10:09 +0000 |
| Message-ID | <87powk4rzm.fsf@bsb.me.uk> |
| In reply to | #29467 |
Joao Rodrigues <groups_jr-1@yahoo.com.br> writes: > In a galaxy far far away, Thomas 'Pointed Ears' Lahn prattled: >> Matheus Suffi wrote: >> >> > I'm in trouble , I need to send a set of numbers to a function , for >> > example: ' 01599874425 ' . >> >> That is _not_ a set of numbers; it is, at best, a set of (decimal) digits >> making up *one* number. > > Matheus was just giving an example. No need for bragging about your > knowledge in Set Theory. Once again, you're missing the point. Sets don't contain duplicates so I would not say he's bragging. <snip> >> 2. <http://www.catb.org/esr/faqs/smart-questions.html> How I hate that document. It has some very sounds advice but I never refer anyone to it because I cringe at the Usenet culture of bullying it endorses. Usenet needs more smart answers than it needs smart questions. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-01-29 10:20 +0000 |
| Message-ID | <d5fmab91iu8mm7umgt5chdm2a99cquc8p6@4ax.com> |
| In reply to | #29470 |
On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote: <snip> >Sets don't contain duplicates <snip> How can you tell? x is a member; x is a member; x is a member. Does that tell you if there is duplication, or not? Remember, there's no other way to look inside a set. John
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-01-29 12:23 +0000 |
| Message-ID | <87twlw376u.fsf@bsb.me.uk> |
| In reply to | #29471 |
John Harris <niam@jghnorth.org.uk.invalid> writes:
> On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse
> <ben.usenet@bsb.me.uk> wrote:
>
> <snip>
>>Sets don't contain duplicates
> <snip>
>
> How can you tell?
x not in (S \ {x}). |{x}| = 1. x in S => |S \ {x}| = |S| - 1. These
are inconsistent with my understanding of the metaphor of duplication
(though I accept it might have other nuances for other people).
> x is a member; x is a member; x is a member.
> Does that tell you if there is duplication, or not? Remember, there's
> no other way to look inside a set.
If you are allowed metaphors like "look" and "inside", so am I!
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-01-29 14:50 +0000 |
| Message-ID | <bpumabtl7f4uhsegn18o1icchhldsv3972@4ax.com> |
| In reply to | #29473 |
On Fri, 29 Jan 2016 12:23:53 +0000, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:
>John Harris <niam@jghnorth.org.uk.invalid> writes:
>
>> On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse
>> <ben.usenet@bsb.me.uk> wrote:
>>
>> <snip>
>>>Sets don't contain duplicates
>> <snip>
>>
>> How can you tell?
>
>x not in (S \ {x}). |{x}| = 1. x in S => |S \ {x}| = |S| - 1. These
>are inconsistent with my understanding of the metaphor of duplication
>(though I accept it might have other nuances for other people).
It depends what you mean by |{x}| = 1. Possibly you mean
a) x occurs only once in {x};
or possibly you mean
b) x is a member of {x} but no other object is.
Now (b) can be defined using the usual set axioms and relations.
But (a) can only be defined if you add an extra axiom and add an extra
relation to the usual two (which are the = and IsMemberOf relations).
>> x is a member; x is a member; x is a member.
>> Does that tell you if there is duplication, or not? Remember, there's
>> no other way to look inside a set.
>
>If you are allowed metaphors like "look" and "inside", so am I!
I could have written "investigate the constituents of", but I chose
not to.
John
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-01-29 16:11 +0000 |
| Message-ID | <87oac41i30.fsf@bsb.me.uk> |
| In reply to | #29480 |
John Harris <niam@jghnorth.org.uk.invalid> writes:
> On Fri, 29 Jan 2016 12:23:53 +0000, Ben Bacarisse
> <ben.usenet@bsb.me.uk> wrote:
>
>>John Harris <niam@jghnorth.org.uk.invalid> writes:
>>
>>> On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse
>>> <ben.usenet@bsb.me.uk> wrote:
>>>
>>> <snip>
>>>>Sets don't contain duplicates
>>> <snip>
>>>
>>> How can you tell?
>>
>>x not in (S \ {x}). |{x}| = 1. x in S => |S \ {x}| = |S| - 1. These
>>are inconsistent with my understanding of the metaphor of duplication
>>(though I accept it might have other nuances for other people).
>
> It depends what you mean by |{x}| = 1. Possibly you mean
> a) x occurs only once in {x};
> or possibly you mean
> b) x is a member of {x} but no other object is.
I intended the conventional meaning of cardinality.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-01-30 10:10 +0000 |
| Message-ID | <ql2pabpigiko0q6o2bafb1blb2hea5raid@4ax.com> |
| In reply to | #29481 |
On Fri, 29 Jan 2016 16:11:31 +0000, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:
>John Harris <niam@jghnorth.org.uk.invalid> writes:
>
>> On Fri, 29 Jan 2016 12:23:53 +0000, Ben Bacarisse
>> <ben.usenet@bsb.me.uk> wrote:
>>
>>>John Harris <niam@jghnorth.org.uk.invalid> writes:
>>>
>>>> On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse
>>>> <ben.usenet@bsb.me.uk> wrote:
>>>>
>>>> <snip>
>>>>>Sets don't contain duplicates
>>>> <snip>
>>>>
>>>> How can you tell?
>>>
>>>x not in (S \ {x}). |{x}| = 1. x in S => |S \ {x}| = |S| - 1. These
>>>are inconsistent with my understanding of the metaphor of duplication
>>>(though I accept it might have other nuances for other people).
>>
>> It depends what you mean by |{x}| = 1. Possibly you mean
>> a) x occurs only once in {x};
>> or possibly you mean
>> b) x is a member of {x} but no other object is.
>
>I intended the conventional meaning of cardinality.
><snip>
With the conventional meaning, the cardinality being 1 means that
there is a bijection between {x} and the set {{}}. Being a bijection
relies on membership, not at all on multiplicity.
John
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2016-01-29 08:35 -0800 |
| Message-ID | <507e7bd8-d774-4f38-aa6b-bf2166d4ecf4@googlegroups.com> |
| In reply to | #29471 |
John Harris wrote: > Ben Bacarisse wrote: > <snip> >> Sets don't contain duplicates > <snip> > How can you tell? > x is a member; x is a member; x is a member. > Does that tell you if there is duplication, or not? Remember, there's > no other way to look inside a set. Sets are usually considered as having cardinalities; for finite sets that most easily represents the count of the number of elements. For implementations in software, there are generally other ways to look into a set, such as iterators, which also make it reasonably clear that there are no duplicates. And if that is unclear, look at the definitions of Bags/Multisets, which intentionally distinguish themselves from Sets precisely on the ability to contain duplicates. -- Scott
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-01-30 10:34 +0000 |
| Message-ID | <534pab1kkcgvjgdglcokpvsf1d68opkg4q@4ax.com> |
| In reply to | #29482 |
On Fri, 29 Jan 2016 08:35:01 -0800 (PST), Scott Sauyet <scott.sauyet@gmail.com> wrote: >John Harris wrote: >> Ben Bacarisse wrote: > >> <snip> >>> Sets don't contain duplicates >> <snip> > >> How can you tell? >> x is a member; x is a member; x is a member. >> Does that tell you if there is duplication, or not? Remember, there's >> no other way to look inside a set. > >Sets are usually considered as having cardinalities; for finite sets that >most easily represents the count of the number of elements. > >For implementations in software, there are generally other ways to look >into a set, such as iterators, which also make it reasonably clear that >there are no duplicates. > >And if that is unclear, look at the definitions of Bags/Multisets, which >intentionally distinguish themselves from Sets precisely on the ability >to contain duplicates. If you take your Multisets and ignore the multiplicities then you have something that has equals and IsMember and obeys the set axioms. It waddles like a set and it quacks like a set so it is therefore (an implementation of) a set. As for implementations in programs, when you choose a data structure to represent small finite sets then it's the application requirements that bias your choice. If lightning fast Union is required but other standard set operations are much less important then you would choose linked lists with Union as concatenation. Then IsMember is slow and Intersection is horrifically slow, and members can occur twice. If you want very fast IsMember you would choose sorted arrays, with IsMember using a binary search. Then it becomes important to ensure that no member occurs many times; Union and Intersection are coded accordingly. John
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2016-01-30 18:53 -0800 |
| Message-ID | <145ed409-7ef0-41ff-a230-59eed64bc0a1@googlegroups.com> |
| In reply to | #29504 |
John Harris wrote:
> Scott Sauyet wrote:
>> And if that is unclear, look at the definitions of Bags/Multisets, which
>> intentionally distinguish themselves from Sets precisely on the ability
>> to contain duplicates.
>
> If you take your Multisets and ignore the multiplicities then you have
> something that has equals and IsMember and obeys the set axioms. It
> waddles like a set and it quacks like a set so it is therefore (an
> implementation of) a set.
I'm trying hard to avoid being too pedantic. This group already has at
least one too many super-pedants.
So, I certainly do understand what you're saying. One can logically
project a Multiset and get a Set.
But you seem to want to have it both ways, claiming that something is
both a Multiset and a Set, and that I can't buy. (At least not in the
case of a Multiset with an element of multiplicity greater than 1.)
You say that if you "ignore the multiplicities...", then it's set-like.
Sure. And if I ignore the composites, the integers act just like the
set of primes.
> As for implementations in programs, when you choose a data structure
> to represent small finite sets then it's the application requirements
> that bias your choice. If lightning fast Union is required but other
> standard set operations are much less important then you would choose
> linked lists with Union as concatenation. Then IsMember is slow and
> Intersection is horrifically slow, and members can occur twice. If you
> want very fast IsMember you would choose sorted arrays, with IsMember
> using a binary search. Then it becomes important to ensure that no
> member occurs many times; Union and Intersection are coded
> accordingly.
I think the important point is here. The discussion about the
mathematical structures offends me, as you seem to conflate the two
notions inappropriately. But you are certainly correct that one can
implement Sets in a number of ways in software, including with
techniques that internally include duplicates. In such techniques,
not only is intersection difficult, though: iteration can also be
a real challenge.
In the end, in software both the API and the performance
characteristics can matter a lot. But for defining whether an
implementation actually meets a spec, it's only the API. And if
multiplicities leak into the API, then it's not a set:
var s = new MySetType(['a', 'b', 'a']);
forEach(s, log);
If this code (for some fairly obvious functions, `forEach` and `log`)
logs two output statements, 'a', and 'b', in some order, then
`MySetType` might well be a Set implementation. But if it logs three
output statements, two 'a's and a 'b', in any order, then it, to my
mind, does not qualify as an implementation of the mathematical notion
of a Set. I'm sure I could write some formal rules to codify this if
I felt really motivated, but this should be clear enough.
This also helps respond to your answer to Ben
(in <ql2pabpigiko0q6o2bafb1blb2hea5raid@4ax.com>):
| With the conventional meaning, the cardinality being 1 means that
| there is a bijection between {x} and the set {{}}. Being a bijection
| relies on membership, not at all on multiplicity.
If you iterate, or list the members of your MultiSet, and the multiply-
occuring ones appear in the list more than once, you have an issue
trying to get a bijection with the appropriate set:
Again, with the Multiset {a, b, a}; by definition, this has cardinality
of 3, but any attempted bijection with {0, 1, 2} will fail, which will
show that it is not a set. Now you could claim that it has a
cardinality of 2, and get proper bijections, but then you're back in
the world of plain Sets and your iterator must only yield two elements.
So I think we may just be arguing about terminology. But if you do
want to claim that you should be able to iterate a Set and see the
underlying implementation's multiplicities repeating themselves, then
our disagreement is fundamental.
-- Scott
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-01-31 14:50 +0000 |
| Message-ID | <nm7sabphgdftsku93djj84mirs818kmspo@4ax.com> |
| In reply to | #29506 |
On Sat, 30 Jan 2016 18:53:10 -0800 (PST), Scott Sauyet
<scott.sauyet@gmail.com> wrote:
>John Harris wrote:
>> Scott Sauyet wrote:
>
>>> And if that is unclear, look at the definitions of Bags/Multisets, which
>>> intentionally distinguish themselves from Sets precisely on the ability
>>> to contain duplicates.
>>
>> If you take your Multisets and ignore the multiplicities then you have
>> something that has equals and IsMember and obeys the set axioms. It
>> waddles like a set and it quacks like a set so it is therefore (an
>> implementation of) a set.
>
>I'm trying hard to avoid being too pedantic. This group already has at
>least one too many super-pedants.
>
>So, I certainly do understand what you're saying. One can logically
>project a Multiset and get a Set.
>
>But you seem to want to have it both ways, claiming that something is
>both a Multiset and a Set, and that I can't buy. (At least not in the
>case of a Multiset with an element of multiplicity greater than 1.)
Be careful. You're in danger of saying ECMAScript can't do integer
arithmetic because all numbers are floating point numbers. Do you
really say 3.0 can't be used as both a floating point number and an
integer?
>You say that if you "ignore the multiplicities...", then it's set-like.
>Sure. And if I ignore the composites, the integers act just like the
>set of primes.
If you look at the Wikipedia article on Multisets you'll see it starts
by saying members of a set can only occur once, then later on quotes a
world class mathematician as saying "The notion of a set takes no
account of multiple occurrence of any one of its members, and yet it
is just this kind of information which is frequently of importance."
<https://en.wikipedia.org/wiki/Multiset#Applications>
>> As for implementations in programs, when you choose a data structure
>> to represent small finite sets then it's the application requirements
>> that bias your choice. If lightning fast Union is required but other
>> standard set operations are much less important then you would choose
>> linked lists with Union as concatenation. Then IsMember is slow and
>> Intersection is horrifically slow, and members can occur twice. If you
>> want very fast IsMember you would choose sorted arrays, with IsMember
>> using a binary search. Then it becomes important to ensure that no
>> member occurs many times; Union and Intersection are coded
>> accordingly.
>
>
>I think the important point is here. The discussion about the
>mathematical structures offends me, as you seem to conflate the two
>notions inappropriately. But you are certainly correct that one can
>implement Sets in a number of ways in software, including with
>techniques that internally include duplicates. In such techniques,
>not only is intersection difficult, though: iteration can also be
>a real challenge.
>
>In the end, in software both the API and the performance
>characteristics can matter a lot. But for defining whether an
>implementation actually meets a spec, it's only the API. And if
>multiplicities leak into the API, then it's not a set:
It's an attempt at a set, but the coding bugs are so horrible that the
program can't be used until they are cured. Regardless of whether you
allow or disallow multiple occurrences there is code that must be got
right, else disaster.
The important thing when implementing sets is not to be afraid of
multiple occurrences. They are mathematically legitimate, but usually
cause more coding problems than they are worth.
<snip>
>This also helps respond to your answer to Ben
>(in <ql2pabpigiko0q6o2bafb1blb2hea5raid@4ax.com>):
Oh dear, a novel :-)
>| With the conventional meaning, the cardinality being 1 means that
>| there is a bijection between {x} and the set {{}}. Being a bijection
>| relies on membership, not at all on multiplicity.
>
>If you iterate, or list the members of your MultiSet, and the multiply-
>occuring ones appear in the list more than once, you have an issue
>trying to get a bijection with the appropriate set:
Who said there can be only one kind of iterator? Who says you can't
have an iterate_first_occurrences_only iterator? It's easy enough to
define; if set contents are always sorted then it's easy enough to
implement.
>Again, with the Multiset {a, b, a}; by definition, this has cardinality
>of 3, but any attempted bijection with {0, 1, 2} will fail, which will
>show that it is not a set.
You are using a different definition of "cardinality". Peculiar
results are to be expected.
>Now you could claim that it has a
>cardinality of 2, and get proper bijections, but then you're back in
>the world of plain Sets and your iterator must only yield two elements.
Exactly. They may be Multisets, but you can use them as sets provided
you write correct code.
>So I think we may just be arguing about terminology. But if you do
>want to claim that you should be able to iterate a Set and see the
>underlying implementation's multiplicities repeating themselves, then
>our disagreement is fundamental.
That's the exact opposite of what I'm saying. Remember, this subthread
started with the question
How can you tell?
(That Sets don't contain duplicates)
John
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2016-01-31 09:56 -0800 |
| Message-ID | <3321806f-18e3-426e-816c-bfe7b7ab0944@googlegroups.com> |
| In reply to | #29507 |
John Harris wrote:
> Scott Sauyet wrote:
>> So, I certainly do understand what you're saying. One can logically
>> project a Multiset and get a Set.
>> But you seem to want to have it both ways, claiming that something is
>> both a Multiset and a Set, and that I can't buy. (At least not in the
>> case of a Multiset with an element of multiplicity greater than 1.)
>
> Be careful. You're in danger of saying ECMAScript can't do integer
> arithmetic because all numbers are floating point numbers. Do you
> really say 3.0 can't be used as both a floating point number and an
> integer?
I was trying to say instead the equivalent of "3.14 isn't also an integer."
Even if we can do some sort of `floor`-based arithmetic with such
representations, we run into fundamental mismatches when we try to add
it to 5.86.
`{a,b}` can be either a Set or a Multiset, but `{a, b, a}` can only be
the latter.
>> You say that if you "ignore the multiplicities...", then it's set-like.
>> Sure. And if I ignore the composites, the integers act just like the
>> set of primes.
> If you look at the Wikipedia article on Multisets you'll see it starts
> by saying members of a set can only occur once, then later on quotes a
> world class mathematician as saying "The notion of a set takes no
> account of multiple occurrence of any one of its members, and yet it
> is just this kind of information which is frequently of importance."
> <https://en.wikipedia.org/wiki/Multiset#Applications>
I never met Rado; he died a few years before I started studying
combinatorics and graph theory, but I knew of him and some of his results.
That statement reads to me as a reason for studying the generalizations
of Sets that are Multisets, not as an argument that Multisets somehow
actually are Sets. Is the latter what you mean to imply when quoting
it?
>> In the end, in software both the API and the performance
>> characteristics can matter a lot. But for defining whether an
>> implementation actually meets a spec, it's only the API. And if
>> multiplicities leak into the API, then it's not a set:
>
> It's an attempt at a set, but the coding bugs are so horrible that the
> program can't be used until they are cured. Regardless of whether you
> allow or disallow multiple occurrences there is code that must be got
> right, else disaster.
>
> The important thing when implementing sets is not to be afraid of
> multiple occurrences. They are mathematically legitimate, but usually
> cause more coding problems than they are worth.
Then I think we do fundamentally disagree.
If they leak into the API, then your API is creating something other
than a Set. If you have the "Set" with elements {a, b, a} and the
iterator for that set will be invoked three time rather than two, then
you have provided something which fails as an implementation of some
reasonable definition of Set. (I know I haven't specified it fully;
I hope it's clear enough, but if you really want me to try to formalize
it I will.)
> <snip>
>> This also helps respond to your answer to Ben
>> (in <ql2pabpigiko0q6o2bafb1blb2hea5raid@4ax.com>):
>
> Oh dear, a novel :-)
:-)
>>| With the conventional meaning, the cardinality being 1 means that
>>| there is a bijection between {x} and the set {{}}. Being a bijection
>>| relies on membership, not at all on multiplicity.
>> If you iterate, or list the members of your MultiSet, and the multiply-
>> occuring ones appear in the list more than once, you have an issue
>> trying to get a bijection with the appropriate set:
> Who said there can be only one kind of iterator? Who says you can't
> have an iterate_first_occurrences_only iterator? It's easy enough to
> define; if set contents are always sorted then it's easy enough to
> implement.
I'm suggesting that there is a standard definition for Set which is
to map the elements against [0, 1, 2, ... (cardinality - 1)], and to
provide an iterator using that mapping. Nothing says this has to be
fixed or ordered in any external manner, only that one can do so.
Again, I know I'm doing a little hand-waving here; formalizing this
is not terribly difficult, but I believe it would add little to the
conversation, so I won't do so unless you insist.
This does not preclude you from providing any other iterators you
like, but the one that helps define a Set is of this type.
And perhaps this is the rub. I'm thinking of the software notion of
Sets here, rather than the mathematical ones. For there is certainly
another notion of sets, that of all values for which a given
predicated returns true. Union and intersection are easily made with
`||` and `&&` on the predicates, and for these there is no notion of
iteration, and also no notion of the usual software Sets as Collections
to which you might add or remove elements, or at least construct with
a fixed set of elements. But I can't see that as our disagreement,
since there is no room for multiplicities in that definition.
>> Again, with the Multiset {a, b, a}; by definition, this has cardinality
>> of 3, but any attempted bijection with {0, 1, 2} will fail, which will
>> show that it is not a set.
>
> You are using a different definition of "cardinality". Peculiar
> results are to be expected.
This is the standard definition of cardinality on a multiset. That same
Wikipedia article [1] describes this well:
| The total number of elements in a multiset, including repeated
| memberships, is the cardinality of the multiset. For example, in
| the multiset {a, a, b, b, b, c} the multiplicities of the members
| a, b, and c are respectively 2, 3, and 1, and the cardinality of
| the multiset is 6.
>> Now you could claim that it has a
>> cardinality of 2, and get proper bijections, but then you're back in
>> the world of plain Sets and your iterator must only yield two elements.
>
> Exactly. They may be Multisets, but you can use them as sets provided
> you write correct code.
I don't know what you mean by saying they may be Multisets, then.
Just because the underlying implementation has two references to the
value does not make something a Multiset. That would be an API
choice.
>> So I think we may just be arguing about terminology. But if you do
>> want to claim that you should be able to iterate a Set and see the
>> underlying implementation's multiplicities repeating themselves, then
>> our disagreement is fundamental.
>
> That's the exact opposite of what I'm saying. Remember, this subthread
> started with the question
> How can you tell?
> (That Sets don't contain duplicates)
Once again, I think I'm back to us being on the same page. The API is
king. If it is a Set according the (or our hypothetical) specification,
then it is a Set, regardless of how it's implemented. But then to my
mind calling it a Multiset it misleading. That too is a public API, and,
while sure, all Sets are Multisets, so trivially a Set is also a Multiset,
fundamentally, you're asserting that there are multiplicities involved,
and in that case, it is not a Set. I believe this API perspective must
necessarily be privileged over the implementor's perspective.
-- Scott
[1]: <https://en.wikipedia.org/wiki/Multiset#Overview>
[toc] | [prev] | [next] | [standalone]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2016-02-01 11:02 +0000 |
| Message-ID | <joeuab92s62fjvgi3jkd3dr3r5et72j6hc@4ax.com> |
| In reply to | #29508 |
On Sun, 31 Jan 2016 09:56:16 -0800 (PST), Scott Sauyet <scott.sauyet@gmail.com> wrote: We appear to be going round in circles so I'll keep it short. <snip> >If they leak into the API, then your API is creating something other >than a Set. <snip> Yup. But I'm not that bad a programmer. >Once again, I think I'm back to us being on the same page. The API is >king. If it is a Set according the (or our hypothetical) specification, >then it is a Set, regardless of how it's implemented. That's what I keep on saying. If someone looks at the source code and says they are not sets because the internal structure isn't what they expect then they are wrong, wrong wrong wrong, very wrong. Even if the internal structure allows duplicates (that are not visible through the API). >But then to my >mind calling it a Multiset it misleading. <snip> You're the one who started talking about multisets, and iterators that don't obey the API for sets, and notation that means different things for sets and multisets. It's been rather confusing. John
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2016-02-01 18:10 -0800 |
| Message-ID | <1155b602-3fdc-41d8-a853-e9361f7fd359@googlegroups.com> |
| In reply to | #29515 |
John Harris wrote: > Scott Sauyet wrote: >> Once again, I think I'm back to us being on the same page. The API is >> king. If it is a Set according the (or our hypothetical) specification, >> then it is a Set, regardless of how it's implemented. > > That's what I keep on saying. > > If someone looks at the source code and says they are not sets because > the internal structure isn't what they expect then they are wrong, > wrong wrong wrong, very wrong. Even if the internal structure allows > duplicates (that are not visible through the API). Then we're definitely on the same page. And then the answer to your original question: |> Sets don't contain duplicates | How can you tell? is a trivially easy, "Obviously they can't." I don't know why you would even ask. :-) -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2016-01-29 09:38 -0800 |
| Message-ID | <cm8nabt8r9lik7lqcimu2v7ijpckjsqk75@4ax.com> |
| In reply to | #29470 |
On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:
[snipped unused attribution]
>> In a galaxy far far away, Thomas 'Pointed Ears' Lahn prattled:
[snip]
>>> 2. <http://www.catb.org/esr/faqs/smart-questions.html>
>How I hate that document. It has some very sounds advice but I never
>refer anyone to it because I cringe at the Usenet culture of bullying it
>endorses. Usenet needs more smart answers than it needs smart
>questions.
It is the best that I have found.
Bullying? It is more like, "Do not waste people's time."
I have read threads more than once where someone supposedly
asking for help dribbled out details a line at a time over a couple of
weeks. I have little patience for such nonsense.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2016-01-29 20:17 +0000 |
| Message-ID | <877fis16po.fsf@bsb.me.uk> |
| In reply to | #29486 |
Gene Wirchenko <genew@telus.net> writes: > On Fri, 29 Jan 2016 10:09:17 +0000, Ben Bacarisse > <ben.usenet@bsb.me.uk> wrote: > > [snipped unused attribution] > >>> In a galaxy far far away, Thomas 'Pointed Ears' Lahn prattled: > > [snip] > >>>> 2. <http://www.catb.org/esr/faqs/smart-questions.html> > >>How I hate that document. It has some very sounds advice but I never >>refer anyone to it because I cringe at the Usenet culture of bullying it >>endorses. Usenet needs more smart answers than it needs smart >>questions. > > It is the best that I have found. Yes, I think it may well be. And as I said, it has lots of very helpful and wise advice there. > Bullying? It is more like, "Do not waste people's time." I believe so, yes. However, since only an emacs/vi debate is likely to provoke more heat, it's probably best to leave it. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-01-29 20:08 +0100 |
| Message-ID | <3183856.lbL3dLxAXy@PointedEars.de> |
| In reply to | #29470 |
Ben Bacarisse wrote: > Joao Rodrigues <groups_jr-1@yahoo.com.br> writes: >> In a galaxy far far away, Thomas 'Pointed Ears' Lahn prattled: >>> Matheus Suffi wrote: >>> > I'm in trouble , I need to send a set of numbers to a function , for >>> > example: ' 01599874425 ' . >>> That is _not_ a set of numbers; it is, at best, a set of (decimal) >>> digits making up *one* number. >> Matheus was just giving an example. No need for bragging about your >> knowledge in Set Theory. Once again, you're missing the point. > > Sets don't contain duplicates so I would not say he's bragging. That is an interesting point – and relevant here given the Set type introduced in ECMAScript 2015 –, but not my point at all. I was pointing out the difference between the terms “number” and “digit” instead. > <snip> >>> 2. <http://www.catb.org/esr/faqs/smart-questions.html> > > How I hate that document. It has some very sounds advice but I never > refer anyone to it because I cringe at the Usenet culture of bullying it > endorses. You have misunderstood it completely. It does not endorse bullying at all. > Usenet needs more smart answers than it needs smart questions. Usenet is not a free helpdesk; it is first and foremost a discussion medium. Good answers require a considerable amount generally helpful people’s *free time*; they should not be a gift, but (should) have to be *earned* by putting *some* effort into solving your own problem first. And a smart question is the best way to show this to one’s readers; it shows that one possesses the basic social and problem-solving skills and the will to use them in order to work on the solution to one’s problem *together*. BTW, that document has been referred by the FAQ of this newsgroup ever since, and that is good so. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web