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


Groups > comp.lang.javascript > #29438 > unrolled thread

passing a set of numbers to a function

Started byMatheus Suffi <matheus.suffi40@gmail.com>
First post2016-01-25 04:45 -0800
Last post2016-02-05 10:51 +0000
Articles 20 on this page of 55 — 13 participants

Back to article view | Back to comp.lang.javascript


Contents

  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 2 of 3 — ← Prev page 1 [2] 3  Next page →


#29474

FromAleksandro <aleksandro@gmx.com>
Date2016-01-29 10:32 -0300
Message-ID<n8fpfi$ovb$1@dont-email.me>
In reply to#29466
On 28/01/16 23:57, Thomas 'PointedEars' Lahn wrote:
> 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).

Matheus, if you want to maximize the usefulness of this site and
minimize the wasted time, I strongly suggest you block Thomas' messages
and all the replies to him. These stupid arguments are common here and
some just keep feeding the troll.

[toc] | [prev] | [next] | [standalone]


#29475

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-01-29 14:53 +0100
Message-ID<XnsA59E97684B4DAeejj99@194.109.6.166>
In reply to#29474
Aleksandro <aleksandro@gmx.com> wrote on 29 Jan 2016 in comp.lang.javascript:

> Matheus, if you want to maximize the usefulness of this site

Despite the good tiding intended, 
there is no site in sight,
this is Usenet.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#29479

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-01-29 06:26 -0800
Message-ID<14e35e53-696f-47fa-979c-4f659a8a580b@googlegroups.com>
In reply to#29475
Evertjan. wrote:
> Aleksandro wrote:
> 
>> Matheus, if you want to maximize the usefulness of this site
> 
> Despite the good tiding intended, 
> there is no site in sight,
> this is Usenet.

The fact that the World Wide Web is using the word "site" for its
locations does not preclude us from using it in other common ways
found in English, such as a synonym for "location", even for such 
an abstraction of "location" that would encompass a USENET group.

See also "forum".

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29478

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-01-29 14:19 +0000
Message-ID<g5tmab5ijjbb9s960crtmgr2psenvsjjbv@4ax.com>
In reply to#29466
On Fri, 29 Jan 2016 03:57:49 +0100, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:


  <snip>
>1. There is no “javascript”,
  <snip>

I don't understand why Thomas will accept "car" as a general name for
a variety of different things with something in common, but won't
accept "javascript" as a general name for a variety of things with
much in common.

If he wrote "There is no *one* javascript" it would cease to be
obnoxious, though lacking in explanation.

  John

[toc] | [prev] | [next] | [standalone]


#29483

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-01-29 08:38 -0800
Message-ID<a9b1fc1e-f513-44f2-b66a-1fab10852b27@googlegroups.com>
In reply to#29478
John Harris wrote:
> Thomas 'PointedEars' Lahn wrote:

>   <snip>
>> 1. There is no "javascript",
>   <snip>

> I don't understand why Thomas will accept "car" as a general name for
> a variety of different things with something in common, but won't
> accept "javascript" as a general name for a variety of things with
> much in common.

Selective pedantry.

It's a disease very common in online discussions.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29484

FromAleksandro <aleksandro@gmx.com>
Date2016-01-29 13:54 -0300
Message-ID<n8g5ar$8co$1@dont-email.me>
In reply to#29483
On 29/01/16 13:38, Scott Sauyet wrote:
> John Harris wrote:
>> Thomas 'PointedEars' Lahn wrote:
> 
>>   <snip>
>>> 1. There is no "javascript",
>>   <snip>
> 
>> I don't understand why Thomas will accept "car" as a general name for
>> a variety of different things with something in common, but won't
>> accept "javascript" as a general name for a variety of things with
>> much in common.
> 
> Selective pedantry.
> 
> It's a disease very common in online discussions.

Online? You are replying offline; that your 'NNTP client´ synchronizes
your NNTP follow-ups to certain NNTP articles from time to time does not
mean that you are actually online.

PS0: Read the FAQ, and learn to ask intelligent questions.
PS1: It's not attribution novel! LOL!!1
PS2: Sorry. lol

[toc] | [prev] | [next] | [standalone]


#29487

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-01-29 10:11 -0800
Message-ID<c4d87ac9-9f23-4b7e-ad7e-6f69b99c35c7@googlegroups.com>
In reply to#29484
Aleksandro wrote:
>Scott Sauyet wrote:
>> John Harris wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>   <snip>
>>>> 1. There is no "javascript",
>>>   <snip>
>> 
>>> I don't understand why Thomas will accept "car" as a general name for
>>> a variety of different things with something in common, but won't
>>> accept "javascript" as a general name for a variety of things with
>>> much in common.
>> 
>> Selective pedantry.
>> 
>> It's a disease very common in online discussions.
> 
> Online? You are replying offline; that your 'NNTP client´ synchronizes
> your NNTP follow-ups to certain NNTP articles from time to time does not
> mean that you are actually online.

I'm sorry, it's hard to read intent sometimes.  Was that intentional irony?

If so, well played.

If not, I must repeat, "selective pedantry".

  -- Scott

[toc] | [prev] | [next] | [standalone]


#29488

FromAleksandro <aleksandro@gmx.com>
Date2016-01-29 15:38 -0300
Message-ID<n8gbdf$1rs$1@dont-email.me>
In reply to#29487
On 29/01/16 15:11, Scott Sauyet wrote:
> Aleksandro wrote:
>> Scott Sauyet wrote:
>>> John Harris wrote:
>>>> Thomas 'PointedEars' Lahn wrote:
>>>>   <snip>
>>>>> 1. There is no "javascript",
>>>>   <snip>
>>>
>>>> I don't understand why Thomas will accept "car" as a general name for
>>>> a variety of different things with something in common, but won't
>>>> accept "javascript" as a general name for a variety of things with
>>>> much in common.
>>>
>>> Selective pedantry.
>>>
>>> It's a disease very common in online discussions.
>>
>> Online? You are replying offline; that your 'NNTP client´ synchronizes
>> your NNTP follow-ups to certain NNTP articles from time to time does not
>> mean that you are actually online.
> 
> I'm sorry, it's hard to read intent sometimes.  Was that intentional irony?
> 
> If so, well played.
> 
> If not, I must repeat, "selective pedantry".

I thought the “PS2: Sorry. lol” left clear the irony. :(

[toc] | [prev] | [next] | [standalone]


#29490

FromAnders Wegge Keller <wegge@geostat.dk>
Date2016-01-29 20:13 +0100
Message-ID<20160129201328.09d6adb9@geostat.dk>
In reply to#29487
On Fri, 29 Jan 2016 10:11:46 -0800 (PST)
Scott Sauyet <scott.sauyet@gmail.com> wrote:

> If not, I must repeat, "selective pedantry".

 That's better than the social handicap of OCP. I suspect that Thomas is not
really able to control the urge to correct even minor cases of imprecise
expression. You should not mock him for it. It is in no way cool or
desirable to be socially handicapped by the uncontrollable desire to
correct people, whenever they say something technically incorrect. 

 I am a long time sufferer of this irrational desire to pick up even the
tiniest nit. Although I'm now able to withstand the desire to argue over the
directionality of rebate percentages or KiB/KB, it has still cost me a
divorce and another broken relationship to get to my present state.

 Don't get me wrong. As this is not my own OCP, I can also see the hilarity.
I also have the occasional urge to fight Thomas over an unpicked nit. But
please -- consider whether you want to stroke your ego, or increase the S/N
ratio. If you want to achieve the latter, please refrain from picking at the
same sore spot.
 
-- 
//Wegge

[toc] | [prev] | [next] | [standalone]


#29492

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-01-29 20:46 +0100
Message-ID<2186616.4jLVtqKeT5@PointedEars.de>
In reply to#29490
Anders Wegge Keller wrote:

> On Fri, 29 Jan 2016 10:11:46 -0800 (PST)
> Scott Sauyet <scott.sauyet@gmail.com> wrote:
>> If not, I must repeat, "selective pedantry".
> 
>  That's better than the social handicap of OCP.

There is no “OCP”.  Perhaps you mean OCD (Obsessive-Compulsive Disorder) or 
OCPD (Obsessive-Compulsive Personality Disorder), and it is a common 
misconception to assume that people who value precision and orderliness 
suffer from OCD or OCPD.  Also, OCPD is often confused with OCD.

See also: <https://youtu.be/tnzz-eFmKaw> (and *please*, if you belong to the 
aforementioned group, educate yourself by also reading the description and 
follow the link therein).

>  I suspect that Thomas is not really able to control the urge to correct 
>  even minor cases of imprecise expression.

I do not suspect, I am certain that you are way out of your league in making 
psychological diagnoses of people you have never met over the Net.  Most 
certainly you are not even a medical practitioner.  Your posting, however 
well meant it might be, is only another big ad hominem argument that 
contributes nothing to solving the problem at hand.  I strongly recommend 
that you contribute something to that cause or go away.  Your kitchen 
psychology is not at all helpful.

Score adjusted

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


#29496

FromAleksandro <aleksandro@gmx.com>
Date2016-01-29 16:59 -0300
Message-ID<n8gg63$jek$1@dont-email.me>
In reply to#29492
On 29/01/16 16:46, Thomas 'PointedEars' Lahn wrote:
> Anders Wegge Keller wrote:
> 
>> On Fri, 29 Jan 2016 10:11:46 -0800 (PST)
>> Scott Sauyet <scott.sauyet@gmail.com> wrote:
>>> If not, I must repeat, "selective pedantry".
>>
>>  That's better than the social handicap of OCP.
> 
> There is no “OCP”.  Perhaps you mean OCD (Obsessive-Compulsive Disorder) or 
> OCPD (Obsessive-Compulsive Personality Disorder), and it is a common 
> misconception to assume that people who value precision and orderliness 
> suffer from OCD or OCPD.  Also, OCPD is often confused with OCD.
> 
> See also: <https://youtu.be/tnzz-eFmKaw> (and *please*, if you belong to the 
> aforementioned group, educate yourself by also reading the description and 
> follow the link therein).
> 
>>  I suspect that Thomas is not really able to control the urge to correct 
>>  even minor cases of imprecise expression.
> 
> I do not suspect, I am certain that you are way out of your league in making 
> psychological diagnoses of people you have never met over the Net.  Most 
> certainly you are not even a medical practitioner.  Your posting, however 
> well meant it might be, is only another big ad hominem argument that 
> contributes nothing to solving the problem at hand.  I strongly recommend 
> that you contribute something to that cause or go away.  Your kitchen 
> psychology is not at all helpful.
> 
> Score adjusted

https://i.imgflip.com/y9jps.jpg

[toc] | [prev] | [next] | [standalone]


#29592

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2016-02-12 12:03 +0100
Message-ID<56bdbbea$0$23821$e4fe514c@news.xs4all.nl>
In reply to#29484
On 1/29/2016 5:54 PM, Aleksandro wrote:
> On 29/01/16 13:38, Scott Sauyet wrote:
>> John Harris wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>
>>>    <snip>
>>>> 1. There is no "javascript",
>>>    <snip>
>>
>>> I don't understand why Thomas will accept "car" as a general name for
>>> a variety of different things with something in common, but won't
>>> accept "javascript" as a general name for a variety of things with
>>> much in common.
>>
>> Selective pedantry.
>>
>> It's a disease very common in online discussions.
>
> Online? You are replying offline; that your 'NNTP client´ synchronizes
> your NNTP follow-ups to certain NNTP articles from time to time does not
> mean that you are actually online.
>
> PS0: Read the FAQ, and learn to ask intelligent questions.
> PS1: It's not attribution novel! LOL!!1
> PS2: Sorry. lol
>

Haha. :-)
Nice one.

Regards,
Erwin Moller

-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#29520

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-02-02 11:18 +0100
Message-ID<22041181.SJtjrm8m6U@PointedEars.de>
In reply to#29438
Stefan Ram wrote:

>   In a JavaScript program, we cannot write expressions whose
>   values are sets, we only can write expressions whose
>   values are instances of an /implementation/ of a set.

Like the built-in Set type.
 
>   The nature of these values depends on the chose of a
>   method to implement sets. Since it is difficult or impossible
>   to write a general implementation that implements all
>   properties of the mathematical concept, […]

It may be difficult, but how did you get the idea that it would be 
impossible?

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


#29521

FromAleksandro <aleksandro@gmx.com>
Date2016-02-02 12:31 -0300
Message-ID<n8qhuj$881$1@dont-email.me>
In reply to#29520
On 02/02/16 07:18, Thomas 'PointedEars' Lahn wrote:
> Stefan Ram wrote:
> 
>>   In a JavaScript program, we cannot write expressions whose
>>   values are sets, we only can write expressions whose
>>   values are instances of an /implementation/ of a set.
> 
> Like the built-in Set type.
>  
>>   The nature of these values depends on the chose of a
>>   method to implement sets. Since it is difficult or impossible
>>   to write a general implementation that implements all
>>   properties of the mathematical concept, […]
> 
> It may be difficult, but how did you get the idea that it would be 
> impossible?

Pedantry at its finest.

[toc] | [prev] | [next] | [standalone]


#29526

FromJohn Harris <niam@jghnorth.org.uk.invalid>
Date2016-02-04 10:42 +0000
Message-ID<dna6bbll0vvjn3gvovc9t822fduak5inlu@4ax.com>
In reply to#29520
On Tue, 02 Feb 2016 11:18:31 +0100, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

>Stefan Ram wrote:
>
>>   In a JavaScript program, we cannot write expressions whose
>>   values are sets, we only can write expressions whose
>>   values are instances of an /implementation/ of a set.
>
>Like the built-in Set type.
> 
>>   The nature of these values depends on the chose of a
>>   method to implement sets. Since it is difficult or impossible
>>   to write a general implementation that implements all
>>   properties of the mathematical concept, […]
>
>It may be difficult, but how did you get the idea that it would be 
>impossible?

I think he may be referring to the difficulty of implementing infinite
sets. A computer program can only implement small finite sets (small
relative to a googolplex).

However, if a program will never reach the limits of its storage space
then it's not possible to demonstrate that it doesn't implement
everything about sets. Only reading the source code would do that.

  John

[toc] | [prev] | [next] | [standalone]


#29527

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-02-04 15:38 +0000
Message-ID<87r3gso59h.fsf@bsb.me.uk>
In reply to#29526
John Harris <niam@jghnorth.org.uk.invalid> writes:

> On Tue, 02 Feb 2016 11:18:31 +0100, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
>
>>Stefan Ram wrote:
>>
>>>   In a JavaScript program, we cannot write expressions whose
>>>   values are sets, we only can write expressions whose
>>>   values are instances of an /implementation/ of a set.
>>
>>Like the built-in Set type.
>> 
>>>   The nature of these values depends on the chose of a
>>>   method to implement sets. Since it is difficult or impossible
>>>   to write a general implementation that implements all
>>>   properties of the mathematical concept, […]
>>
>>It may be difficult, but how did you get the idea that it would be 
>>impossible?
>
> I think he may be referring to the difficulty of implementing infinite
> sets. A computer program can only implement small finite sets (small
> relative to a googolplex).

Computer programs can implement infinite sets though only very few of
them (even fewer, compared to how many there are, than for finite sets).

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#29529

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-02-04 17:33 +0100
Message-ID<1603158.xI32ru06Pi@PointedEars.de>
In reply to#29527
Ben Bacarisse wrote:

> John Harris […] writes:
>> […] Thomas 'PointedEars' Lahn […] wrote:
>>> Stefan Ram wrote:
>>>>   The nature of these values depends on the chose of a
>>>>   method to implement sets. Since it is difficult or impossible
>>>>   to write a general implementation that implements all
>>>>   properties of the mathematical concept, […]
>>> It may be difficult, but how did you get the idea that it would be
>>> impossible?
>> I think he may be referring to the difficulty of implementing infinite
>> sets. A computer program can only implement small finite sets (small
>> relative to a googolplex).
> 
> Computer programs can implement infinite sets though only very few of
> them (even fewer, compared to how many there are, than for finite sets).

AFAICS there is no intrinsic limit as to the implementation of infinite sets 
(you just need a flexible enough data model to define them), however it 
appears to be non-trivial to implement operations on some of them, for 
example to determine if an item is an element of such a set.

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


#29531

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-04 16:19 -0800
Message-ID<58b65993-5943-4f8e-a4e2-9e97bb1feea3@googlegroups.com>
In reply to#29529
Thomas 'PointedEars' Lahn wrote:
> Ben Bacarisse wrote:

>> Computer programs can implement infinite sets though only very few of
>> them (even fewer, compared to how many there are, than for finite sets).
> 
> AFAICS there is no intrinsic limit as to the implementation of infinite sets 
> (you just need a flexible enough data model to define them), however it 
> appears to be non-trivial to implement operations on some of them, for 
> example to determine if an item is an element of such a set.

There is a simple way to implement mathematical sets, finite or 
infinite using predicate functions.  But true sets from a mathematical 
perspective are very different from the sorts of Set types usually 
considered in software: collections to which items might be added or 
removed.

But for those interested in sets which have the normal set operations 
of `contains`, `union`, `intersection`, and `complement`, the 
following looks to be quite simple:

    const set = pred => ({
      contains: pred,
      union: set2 => set(val => pred(val) || set2.contains(val)),
      intersection: set2 => set(val => pred(val) && set2.contains(val)),
      complement: () => set(val => !pred(val))
    });

One could use this to create sets such as these:

    const fizz = set(n => n % 3 == 0);
    const buzz = set(n => n % 5 == 0);
    const fizzBuzz = fizz.intersection(buzz);
    const fizzOrBuzz = fizz.union(buzz);
    const notBuzz = buzz.complement();

These are somewhat oversimplified, as they should probably also test 
that the value supplied is a number, but the basic idea should be 
clear.

If you wanted to test them, this should make it clear how these sets 
work:

    const test = (s, nbrs) => nbrs.reduce((acc, val) => {
      acc[val] = s.contains(val);
      return acc;
    }, {})

    test(fizz, [6, 10, 14, 45]); 
    //=> {6: true, 10: false, 14: false, 45: true}

    test(buzz, [6, 10, 14, 45]); 
    //=> {6: false, 10: true, 14: false, 45: true}

    test(fizzBuzz, [6, 10, 14, 45]);
    //=> {6: false, 10: false, 14: false, 45: true}

    test(fizzOrBuzz, [6, 10, 14, 45]); 
    //=> {6: true, 10: true, 14: false, 45: true}

    test(notBuzz, [6, 10, 14, 45]);
    //=> {6: true, 10: false, 14: true, 45: false}

But, for one trying to use a set as a Collection, these are missing 
several important features.  Obviously there is no way to add or 
remove members.  There is also no generic way to iterate, although 
obviously one could create iterators to match specific Sets.  So, 
while this is reasonably close to mathematical sets, they are not 
really close to what are usually considered sets in software.

We should also note that this misses at least one important notion 
from mathematics as well.  I'm fairly certain that there is no way to 
write a `subset` function.  I haven't proven this, but I'm guessing 
that the sort of logic that shows that the Halting Problem is 
insoluble or the logic that proves Rice's Theorem would also 
demonstrate that this can't be done.


  -- Scott

[toc] | [prev] | [next] | [standalone]


#29533

FromStefan Weiss <krewecherl@gmail.com>
Date2016-02-05 14:06 +0100
Message-ID<n926p5$rqt$1@news.albasani.net>
In reply to#29531
On 02/05/2016 01:19, Scott Sauyet wrote:
> There is a simple way to implement mathematical sets, finite or 
> infinite using predicate functions. [...]
> 
> But for those interested in sets which have the normal set operations 
> of `contains`, `union`, `intersection`, and `complement`, the 
> following looks to be quite simple:
> 
>     const set = pred => ({
>       contains: pred,
>       union: set2 => set(val => pred(val) || set2.contains(val)),
>       intersection: set2 => set(val => pred(val) && set2.contains(val)),
>       complement: () => set(val => !pred(val))
>     });
> 
> One could use this to create sets such as these:
> 
>     const fizz = set(n => n % 3 == 0);
>     const buzz = set(n => n % 5 == 0);
>     const fizzBuzz = fizz.intersection(buzz);
>     const fizzOrBuzz = fizz.union(buzz);
>     const notBuzz = buzz.complement();

A very nice example.

[snip tests]

> But, for one trying to use a set as a Collection, these are missing 
> several important features.  Obviously there is no way to add or 
> remove members.  There is also no generic way to iterate, although 
> obviously one could create iterators to match specific Sets.  So, 
> while this is reasonably close to mathematical sets, they are not 
> really close to what are usually considered sets in software.
> 
> We should also note that this misses at least one important notion 
> from mathematics as well.  I'm fairly certain that there is no way to 
> write a `subset` function.

Why? Wouldn't "subset" just be one more predicate to be combined with
the set's predicate? "intersection" already does that. The same would go
for adding or removing individual members or (sub)sets, using "union"
and "intersection", respectively.

As for iterators, sets don't have an inherent order, so any kind of
ordered iteration would be an extension to the concept. The ability to
produce members, in any order, is also not a required property of a set.

As implemented above, the sets have no information about their size
(cardinality) or individual members. For example, `set(n => n === 1)`
only has the number 1 as member, but we can't ask it how many members it
contains or to produce one of them.

It seems to me that sets implemented with predicates are mostly useful
for reasoning about very large or infinite sets. For finite sets (that a
computer could count), different implementations will usually be more
practical.


- stefan

[toc] | [prev] | [next] | [standalone]


#29536

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-02-05 05:45 -0800
Message-ID<7de86700-d479-49ff-819f-8187843a09b8@googlegroups.com>
In reply to#29533
Stefan Weiss wrote:
> Scott Sauyet wrote:
>> There is a simple way to implement mathematical sets, finite or 
>> infinite using predicate functions. [...]
>> 
>> But for those interested in sets which have the normal set operations 
>> of `contains`, `union`, `intersection`, and `complement`, the 
>> following looks to be quite simple:
>> 
>>     const set = pred => ({
>>       contains: pred,
>>       union: set2 => set(val => pred(val) || set2.contains(val)),
>>       intersection: set2 => set(val => pred(val) && set2.contains(val)),
>>       complement: () => set(val => !pred(val))
>>     });
> 
> A very nice example.

Thanks.

>> But, for one trying to use a set as a Collection, these are missing 
>> several important features.  Obviously there is no way to add or 
>> remove members.  There is also no generic way to iterate, although 
>> obviously one could create iterators to match specific Sets.  So, 
>> while this is reasonably close to mathematical sets, they are not 
>> really close to what are usually considered sets in software.
>> 
>> We should also note that this misses at least one important notion 
>> from mathematics as well.  I'm fairly certain that there is no way to 
>> write a `subset` function.
> 
> Why? Wouldn't "subset" just be one more predicate to be combined with
> the set's predicate? "intersection" already does that. The same would go
> for adding or removing individual members or (sub)sets, using "union"
> and "intersection", respectively.

I just had the same realization about adding and removing members.

But unless I'm missing something fundamental, I don't see how `subset`
would work in the general case.  It's not an operation like `intersection`
`union`, `add`, etc, but a predicate like `contains`.

If you are given `set(fn)` and want to know if set(x => x == ~~x) (the integers) is a subset of it, how would you test?  What if fn was x => x == ~~x && x != 9007199254740990?


> As for iterators, sets don't have an inherent order, so any kind of
> ordered iteration would be an extension to the concept. The ability to
> produce members, in any order, is also not a required property of a set.

Right, but most software implementations of set make it part of some
group of types that can be iterated.  Since the storage mechanism would
generally allow one to impose an order, even if it's not logical (think
Java's hash-code order, for instance), it's not too strange to assume
that a (finite) set can be iterated.  Of course this makes no sense at
all for an uncountably infinite set.


> As implemented above, the sets have no information about their size
> (cardinality) or individual members. For example, `set(n => n === 1)`
> only has the number 1 as member, but we can't ask it how many members it
> contains or to produce one of them.

And I cannot think of any reasonable way to extend this style 
implementation to add that information.


> It seems to me that sets implemented with predicates are mostly useful
> for reasoning about very large or infinite sets. For finite sets (that a
> computer could count), different implementations will usually be more
> practical.

I wasn't thinking about practical implementation at all.  There were simply
discussions about infinite sets here, and I realized that it's actually
quite straightforward to discuss true sets with code.  If your needs are
covered by `contains`, `union`, `intersection`, `complement`, `add`, 
`remove` and potential derived operations such as `difference`, and if you 
can write predicate functions easily enough for your sets (obviously trivial
for a fixed list), then these might be practical.  If you're doing a lot
of `add`s and/or `remove`s, these would probably be inefficient.

But they're an interesting exercise regardless.

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web