Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Comparing arraies

Reply
Thread Tools

Comparing arraies

 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-30-2012
John G Harris wrote:

> Thomas 'PointedEars' Lahn wrote:
>> John G Harris wrote:

>
> <snip a lot of Lahn silliness>


*plonk*

>> I am aware of operator overloading (e. g. in C++), but we are not
>> discussing those languages or possible implementations of ECMAScript
>> written in those
>> languages. We are discussing the syntax of ECMAScript (implementations).
>> And again, in the syntax of ECMAScript, `+' is an operator; it has
>> operands, not arguments.

>
> Attention! Thomas has forbidden the Mozilla team to contemplate adding
> operator overloading in *any* future version of JavaScript ... because
> it destroys his case.


No, I have not.

> Wikipedia and an online dictionary agree with me : operators are just
> functions it's convenient to distinguish from other functions.
>
> <http://foldoc.org/operator>


And now look up "function" there, stupid.

> <http://en.wikipedia.org/wiki/Operator_(programming)>


That is a reference (a doubtful one at that), but not a proof for your
statement. In fact, it happens to confirm what I have said (although
citations are lacking).

Troll away.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$>
 
Reply With Quote
 
 
 
 
Michael Haufe (TNO)
Guest
Posts: n/a
 
      01-30-2012
On Jan 30, 9:27*am, John G Harris <j...@nospam.demon.co.uk> wrote:

> Wikipedia and an online dictionary agree with me : operators are just
> functions it's convenient to distinguish from other functions.


An operator is not necessarily a function in the strict mathematical
sense. It COULD be a function. For example:

y^2 + 3x = 6

Is not a function, but a relation. Since this is JavaScript we are
talking about and not a Logic Language, Functional language, nor a
Proof assistant, it is generally understood that a "function" really
means "procedure" with potential side-effects.
 
Reply With Quote
 
 
 
 
John G Harris
Guest
Posts: n/a
 
      01-31-2012
On Mon, 30 Jan 2012 at 12:01:28, in comp.lang.javascript, Michael Haufe
(TNO) wrote:
>On Jan 30, 9:27*am, John G Harris <j...@nospam.demon.co.uk> wrote:
>
>> Wikipedia and an online dictionary agree with me : operators are just
>> functions it's convenient to distinguish from other functions.

>
>An operator is not necessarily a function in the strict mathematical
>sense. It COULD be a function. For example:
>
>y^2 + 3x = 6
>
>Is not a function, but a relation.


But every relation can be re-defined as a function from the inputs to
the set {true, false}. This is what C, etc, do with the == 'relation' :
it's a function that returns a boolean value.


>Since this is JavaScript we are
>talking about and not a Logic Language, Functional language, nor a
>Proof assistant, it is generally understood that a "function" really
>means "procedure" with potential side-effects.


Surely most descriptions of procedures say that they are functions with
no return value (void functions in C terminology).


John
--
John Harris
 
Reply With Quote
 
Michael Haufe (TNO)
Guest
Posts: n/a
 
      01-31-2012
On Jan 31, 5:06*am, John G Harris <j...@nospam.demon.co.uk> wrote:
>
> But every relation can be re-defined as a function from the inputs to
> the set {true, false}. This is what C, etc, do with the == 'relation':
> it's a function that returns a boolean value.


Not every relation is a predicate, but I think I understand what you
are trying to say.

This is where Mathematicians and Physicists tend to get sloppy. When
it comes to the hand-manipulation of symbols, Math is more an
impressionistic language than a rigorous one. Generally you'll notice
that the common practice is to treat single element sets and the
single element of that set as the same thing, where clearly they are
not and do not share the same operations:

sqrt 9 != sqrt {9}

One cannot take the sqrt of a set. sqrt is not defined in the Algebra
of Sets.

So while we could step back and just say every function is simply:

f : Set -> Set

That lacks an enormous amount of expressiveness.

> Surely most descriptions of procedures say that they are functions with
> no return value (void functions in C terminology).


But they MIGHT return a value. They could also launch the missiles as
a side-effect. They may not return the same value twice when called
twice. They could also throw exceptions, or a number of other things.
Regardless of whether the word "function" is used as its name or as
part of the description, they clearly are not the same "function" that
has been used mathematically or in PLs with better foundations. In
most PLs the word "function" is more impressionistic than something of
substance.
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      01-31-2012
On Mon, 30 Jan 2012 at 19:03:23, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:
>John G Harris wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> John G Harris wrote:

>>
>> <snip a lot of Lahn silliness>

>
>*plonk*


***Plonkity plonk***

I could have said Troll! or Newbie! or Idiot! as Thomas would do, but I
said silly; it's more polite.


>>> I am aware of operator overloading (e. g. in C++), but we are not
>>> discussing those languages or possible implementations of ECMAScript
>>> written in those
>>> languages. We are discussing the syntax of ECMAScript (implementations).
>>> And again, in the syntax of ECMAScript, `+' is an operator; it has
>>> operands, not arguments.

>>
>> Attention! Thomas has forbidden the Mozilla team to contemplate adding
>> operator overloading in *any* future version of JavaScript ... because
>> it destroys his case.

>
>No, I have not.


"We are discussing the syntax of ECMAScript" says otherwise.


>> Wikipedia and an online dictionary agree with me : operators are just
>> functions it's convenient to distinguish from other functions.
>>
>> <http://foldoc.org/operator>

>
>And now look up "function" there, stupid.


I look up 'function' in Foldoc and find it says what it ought to say.
What point are you trying to make?


>> <http://en.wikipedia.org/wiki/Operator_(programming)>

>
>That is a reference (a doubtful one at that), but not a proof for your
>statement.


'Proof'? Who said 'proof'? You must be hoping to get the job of
propaganda minister. What I said was that here are two sources that
agree with me.


>In fact, it happens to confirm what I have said (although
>citations are lacking).


Again you'll have to explain. What I see are almost the same words I
used.


>Troll away.


Silly Thomas.


John
--
John Harris
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      01-31-2012
On Tue, 31 Jan 2012 at 06:08:57, in comp.lang.javascript, Michael Haufe
(TNO) wrote:
>On Jan 31, 5:06*am, John G Harris <j...@nospam.demon.co.uk> wrote:
>>
>> But every relation can be re-defined as a function from the inputs to
>> the set {true, false}. This is what C, etc, do with the == 'relation' :
>> it's a function that returns a boolean value.

>
>Not every relation is a predicate, but I think I understand what you
>are trying to say.


I'll say it in more detail. The main, or only, part of a relation is
represented by a set of tuples, each with the same number of elements.
The elements in a tuple are the arguments or operands, whichever you
prefer to say. If a tuple is in the set then the relation is true for
those elements, if not then it's false. There is obviously a function
from tuples to bool that gives the same answer.


>This is where Mathematicians and Physicists tend to get sloppy. When
>it comes to the hand-manipulation of symbols, Math is more an
>impressionistic language than a rigorous one.


Professional mathematicians are usually rigorous, but they have an
annoying habit of switching to shorthand notation without saying so. I
suspect it's because they do it to students and expect them to work it
out for themselves, and provide the full gruesome working just once,
yawn, yawn.


>Generally you'll notice
>that the common practice is to treat single element sets and the
>single element of that set as the same thing, where clearly they are
>not and do not share the same operations:
>
>sqrt 9 != sqrt {9}
>
>One cannot take the sqrt of a set. sqrt is not defined in the Algebra
>of Sets.


I think this is more often something computer scientists do.


>So while we could step back and just say every function is simply:
>
>f : Set -> Set
>
>That lacks an enormous amount of expressiveness.


You should also use the partial function symbol, something like |-> .
Functions defined for all sets are very dangerous. (They can't be
represented by sets for a start).


>> Surely most descriptions of procedures say that they are functions with
>> no return value (void functions in C terminology).

>
>But they MIGHT return a value. They could also launch the missiles as
>a side-effect. They may not return the same value twice when called
>twice. They could also throw exceptions, or a number of other things.
>Regardless of whether the word "function" is used as its name or as
>part of the description, they clearly are not the same "function" that
>has been used mathematically or in PLs with better foundations. In
>most PLs the word "function" is more impressionistic than something of
>substance.


To put it crudely, a procedure doesn't have a return statement, so it
can't 'return' a value.

If you want to describe side effects then you have to say that the
function is from system state to system state. The input state includes
places to hold the arguments, and places holding anything else that
affects the result. The output state includes a place to hold the
result, if any, and places holding the consequences of side effects,
including the effects of an exception.

Defining just the arguments and result is only a part of the complete
description, but an important part of course.

As for launching missiles when your sqrt function goes wrong, the output
state simply has more empty missile silos.


John
--
John Harris
 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      01-31-2012
In comp.lang.javascript message <>,
Mon, 30 Jan 2012 19:03:23, Thomas 'PointedEars' Lahn
<> posted:

>John G Harris wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> John G Harris wrote:

>>
>> <snip a lot of Lahn silliness>

>
>*plonk*


Plonking someone and continuing to reply to their article is unusually
childish, even for you.

--
(c) John Stockton, nr London UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
 
Reply With Quote
 
Michael Haufe (TNO)
Guest
Posts: n/a
 
      02-01-2012
On Jan 31, 10:08*am, John G Harris <j...@nospam.demon.co.uk> wrote:
> On Tue, 31 Jan 2012 at 06:08:57, in comp.lang.javascript, Michael Haufe
>
> (TNO) wrote:
> >On Jan 31, 5:06*am, John G Harris <j...@nospam.demon.co.uk> wrote:

>
> >> But every relation can be re-defined as a function from the inputs to
> >> the set {true, false}. This is what C, etc, do with the == 'relation' :
> >> it's a function that returns a boolean value.

>
> >Not every relation is a predicate, but I think I understand what you
> >are trying to say.

>
> I'll say it in more detail. The main, or only, part of a relation is
> represented by a set of tuples, each with the same number of elements.
> The elements in a tuple are the arguments or operands, whichever you
> prefer to say. If a tuple is in the set then the relation is true for
> those elements, if not then it's false. There is obviously a function
> from tuples to bool that gives the same answer.



A relation can be redefined using multiple functions, and you can
place those functions into a set. You can then define a function from
that set to the set of booleans. This does not make the latter
function the same as the original relation.


> >One cannot take the sqrt of a set. sqrt is not defined in the Algebra
> >of Sets.

>
> I think this is more often something computer scientists do.


Based on what do you come to this conclusion?

> >So while we could step back and just say every function is simply:

>
> >f : Set -> Set

>
> >That lacks an enormous amount of expressiveness.

>
> You should also use the partial function symbol, something like |-> .
> Functions defined for all sets are very dangerous. (They can't be
> represented by sets for a start).


I suggest glancing at Axiomatic Set Theory then.

> To put it crudely, a procedure doesn't have a return statement, so it
> can't 'return' a value.


Since procedures can branch, and can branch back to the caller, it is
possible to "return". There are versions of SQL with "return"
statements in procedures for example.

> If you want to describe side effects then you have to say that the
> function is from system state to system state. The input state includes
> places to hold the arguments, and places holding anything else that
> affects the result. The output state includes a place to hold the
> result, if any, and places holding the consequences of side effects,
> including the effects of an exception.


That is one possible method, but neither the 'function' of JavaScript
or any other language you've mentioned do this. To repeat what has
been said earlier: it does not matter what word is used in the
language, 'function' is not a true function in the mathematical sense,
nor can all of the operators of the language.


> As for launching missiles when your sqrt function goes wrong, the output
> state simply has more empty missile silos.


And since the language doesn't represent this in its syntax or
semantics, such "functions" are still not.
 
Reply With Quote
 
John G Harris
Guest
Posts: n/a
 
      02-01-2012
On Tue, 31 Jan 2012 at 18:32:35, in comp.lang.javascript, Michael Haufe
(TNO) wrote:
>On Jan 31, 10:08*am, John G Harris <j...@nospam.demon.co.uk> wrote:


<snip>
>A relation can be redefined using multiple functions, and you can
>place those functions into a set. You can then define a function from
>that set to the set of booleans. This does not make the latter
>function the same as the original relation.


I don't know why you think it's so complicated. You have a function
that, given (2, 3) returns true if 2 < 3, false if not, and the same
rule for all other pairs of numbers. That's all.

When you do
var a = 2 < 3;
the language is using the functional version of < (with extra rules for
NaN and other peculiar values).


>> >One cannot take the sqrt of a set. sqrt is not defined in the Algebra
>> >of Sets.

>>
>> I think this is more often something computer scientists do.

>
>Based on what do you come to this conclusion?


It's my impression based on reading books, articles, and papers.


>> >So while we could step back and just say every function is simply:

>>
>> >f : Set -> Set

>>
>> >That lacks an enormous amount of expressiveness.

>>
>> You should also use the partial function symbol, something like |-> .
>> Functions defined for all sets are very dangerous. (They can't be
>> represented by sets for a start).

>
>I suggest glancing at Axiomatic Set Theory then.


Which do you prefer : ZF or VNB? What I said is true in both.

(Hint: Russel's paradox).


>> To put it crudely, a procedure doesn't have a return statement, so it
>> can't 'return' a value.

>
>Since procedures can branch, and can branch back to the caller, it is
>possible to "return". There are versions of SQL with "return"
>statements in procedures for example.


The definition of procedure and function varies from language to
language. In Pascal they are keywords. A procedure must not have a
return value, a function must. In C and relatives it's common to use
procedure for functions that do not return a value (void functions).

An ECMAScript function cannot be flagged as void, but if it doesn't
return a value or always returns undefined then we can call it a
procedure if we wish. But if it causes arguments then we mustn't use the
word.


>> If you want to describe side effects then you have to say that the
>> function is from system state to system state. The input state includes
>> places to hold the arguments, and places holding anything else that
>> affects the result. The output state includes a place to hold the
>> result, if any, and places holding the consequences of side effects,
>> including the effects of an exception.

>
>That is one possible method, but neither the 'function' of JavaScript
>or any other language you've mentioned do this. To repeat what has
>been said earlier: it does not matter what word is used in the
>language, 'function' is not a true function in the mathematical sense,
>nor can all of the operators of the language.


Have a look at ECMA 262 v5.1, section 15.9.5.27 where it defines a Date
object's setTime method. The method has side effects. The method's
definition describes the changes to the system state outside the return
value.

In what way is this not mathematical?


>> As for launching missiles when your sqrt function goes wrong, the output
>> state simply has more empty missile silos.

>
>And since the language doesn't represent this in its syntax or
>semantics, such "functions" are still not.


It does in C++. It's called 'undefined behaviour'. It's what happens if
you break a rule that the compiler can't catch. E.g if you break a
precondition.


John
--
John Harris
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      02-01-2012
Michael Haufe (TNO) wrote:

> On Jan 31, 10:08 am, John G Harris <j...@nospam.demon.co.uk> wrote:
>> If you want to describe side effects then you have to say that the
>> function is from system state to system state. The input state includes
>> places to hold the arguments, and places holding anything else that
>> affects the result. The output state includes a place to hold the
>> result, if any, and places holding the consequences of side effects,
>> including the effects of an exception.

>
> That is one possible method, but neither the 'function' of JavaScript
> or any other language you've mentioned do this. To repeat what has
> been said earlier: it does not matter what word is used in the
> language, 'function' is not a true function in the mathematical sense,
> nor can all of the operators of the language.


I have to disagree here. That the outcome of a programmatic function, given
the same arguments in the same order, is not necessarily the same always,
and there may be side-effects, is what distinguishes it from a programmatic
operator.

With such a programmatic operator, by definition the outcome must be the
same given the same operand(s) in the same order (or the operator becomes
ambiguous and useless). It is therefore an non-injective *mathematical*
function of the operands, from the sets that the operands may belong to, to
the set of the result type. But it is _not_ a function in the *syntax* of
any programming language, not even C++, because you *need to* tell the two
kinds apart to make sense of the syntax, i. e. to parse the program.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing the array in parallel srinukasam VHDL 3 07-30-2005 12:27 PM
comparing the array for generic parameters srinukasam VHDL 3 06-30-2005 07:40 PM
comparing the contents of memory srinukasam VHDL 5 06-23-2005 07:49 PM
[VHDL] Comparing entity and component declarations M.D. van de Burgwal VHDL 3 10-07-2004 08:58 AM
Comparing values in 2 textfiles and returning the missing values Jorgen Gustafsson Perl 4 12-12-2003 09:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57