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


Groups > comp.lang.javascript > #31313

Re: How would you prepare for javascripting interview?

From Scott Sauyet <scott@sauyet.com>
Newsgroups comp.lang.javascript
Subject Re: How would you prepare for javascripting interview?
Date 2016-09-11 02:45 +0000
Organization A noiseless patient Spider
Message-ID <nr2gft$esh$1@dont-email.me> (permalink)
References (10 earlier) <9cstsb1uddjiltlflrdiks2ha2u3msi1ao@4ax.com> <nqnqu2$a4v$1@dont-email.me> <f4i0tbtk1d2sgoqenh8cm8tl6itpk6prqk@4ax.com> <nqvilf$a4r$1@dont-email.me> <nr1965$6qh$1@dont-email.me>

Show all headers | View raw


Doc O'Leary wrote:
> Scott Sauyet wrote:

>>     max([1, 2, 3])                   // 3 
>>     == max(max([1]), max([2, 3]))    // max(1, 3) == 3
>>     == max(max([1, 2]), max([3]))    // max(2, 3) == 3
>>     != max(max([]), max([1, 2, 3]))  // max(NaN, 3) == NaN
>> 
>> Just by partitioning a set differently we can change its maximum.
> 
> People need to stop making this mistaken argument.  This has nothing 
> to do with the mathematical sets.  It has to do with a function in a 
> library of computer code.  

Sorry, I should have used "list" here rather than "set".  I tend to use
the word "list" rather than "array" because of my work in Ramda, where
we work with many iterable collections, but where things might fail
horribly if you pass sparse arrays.  But this has little to do with
mathematics.  I was simply pointing out that if `max([]); //=> NaN`,
then we get some awkward behavior, a violation of the law I was proposing.

If you split a list into two sublists and take the max of each, then the
max of those two resulting values, logically, you should get the same
result as if you took the max of the initial list.  Returning `NaN`
fails this, as demonstrated.  Throwing is a different beast, because then
you simply don't get a value.  Returning `undefined`/`null` could go 
either way, depending upon their implementation, but it strikes me as 
illogical behavior to skip bad values so that `max([8, 6, 7, null, 5, 3, 
undefined, 0, 9]); //=> 9`  Still, this is within the realm of 
possibility.


> Even if it were implemented recursively, 
> it would be poorly programmed if it made a call of max([]), regardless 
> of what such a call might return.

I'm sorry, but I make no sense of this.


>> I lean toward the latter partly because I've done a lot of 
>> mathematical programming over the years (yes, even in Javascript) so 
>> having useful mathematical functions is important to me
> 
> And that’s a fine argument, and especially appropriate here because 
> we *are* talking about what is implemented by the Math object.  But 
> I would still argue that JS is not well-considered when it comes to 
> other objects (the some/every methods of Array) or even other methods 
> in Math (pow has a right identity, but still requires 2 arguments).  
> The inconsistencies make things ugly.

I'm not sure what you're talking about with `Math.pow`, but I certainly 
agree with the general point.  JS is full of warts.



 
>> What I meant about the definition is that if you try to define these 
>> functions as returning the largest elements of their lists you start 
to 
>> raise questions of references versus values, of how to handle ties; it 
>> simply becomes tricky.
> 
> *All* of computer science is essentially about the “tricky” stuff 
> that mathematics drops the ball on.  If people don’t like dealing 
> with complexity like that, they shouldn’t be in the field.

And the goal of API design is to abstract away that complexity, providing 
simple interfaces to users.

I was suggesting that my definition ("max returns the smallest value that
is no smaller than any element in the list") allows us to capture the
meaning of the function faithfully, return something useful mathematically
in every case, and does this as simply as possible.  Alternatives that
attempt to suggest that the function returns an element of the list add
complexity and have no advantage.

I'm sure that our views are colored by our various tolerance for things
such as exceptions (which I mostly hate) and Infinity (which bothers me
not at all), but I think it's hard to argue that this definition is not 
simpler than such alternatives.

  -- Scott

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 09:10 -0700
  Re: How would you prepare for javascripting interview? Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2016-07-18 18:37 +0200
    Re: How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 11:09 -0700
      Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-07-21 01:04 +0000
        Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-07-21 14:24 +0100
        Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-23 16:25 +0200
          Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-07-23 15:56 +0000
            Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-03 19:39 +0000
              Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-04 15:56 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 00:06 +0100
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-05 14:49 +0100
                Re: How would you prepare for javascripting interview? $Bill <news@todbe.com> - 2016-09-05 10:01 -0700
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-06 09:36 -0700
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-05 15:05 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-05 20:31 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 15:15 +0000
                Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-09-06 19:40 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-06 19:25 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-06 22:16 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-07 17:17 +0100
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-07 20:07 +0200
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-08 14:36 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-05 18:46 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 20:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-05 17:27 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 20:12 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:48 +0000
                Re: How would you prepare for javascripting interview? Andreas Bergmaier <andber93@web.de> - 2016-09-06 19:56 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 20:16 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-07 10:01 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 20:21 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-09 11:41 -0700
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-09 15:35 -0700
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-09 20:40 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 15:12 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-12 11:14 -0700
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-13 21:07 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:20 +0000
                Re: How would you prepare for javascripting interview? Ken Tilton <kentilton@gmail.com> - 2016-09-05 11:37 -0700
                Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-09-06 19:26 +0200
                Re: How would you prepare for javascripting interview? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-09-08 12:41 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-05 20:37 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-05 22:13 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-06 02:33 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-06 16:02 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-06 09:50 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-07 01:36 +0000
                Re: How would you prepare for javascripting interview? Gene Wirchenko <genew@telus.net> - 2016-09-07 10:07 -0700
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 00:03 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 00:12 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 15:34 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-11 01:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 19:26 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-13 01:02 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-13 21:38 +0000
                Re: How would you prepare for javascripting interview? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-09-14 00:56 +0200
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:09 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-14 00:47 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:34 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-11 02:45 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 19:10 +0000
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-12 21:06 +0100
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-07 03:12 +0000
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-07 19:53 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-10 02:14 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-10 11:25 +0100
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-10 15:49 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-10 18:39 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-11 02:45 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-11 16:23 +0100
                Re: How would you prepare for javascripting interview? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-12 20:32 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-12 18:49 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-13 00:27 +0000
                Re: How would you prepare for javascripting interview? Tim Streater <timstreater@greenbee.net> - 2016-09-13 08:51 +0100
                Re: How would you prepare for javascripting interview? Jon Ribbens <jon+usenet@unequivocal.eu> - 2016-09-13 12:33 +0000
                Re: How would you prepare for javascripting interview? Scott Sauyet <scott@sauyet.com> - 2016-09-14 01:17 +0000
                Re: How would you prepare for javascripting interview? Tim Streater <timstreater@greenbee.net> - 2016-09-14 11:15 +0100
                Re: How would you prepare for javascripting interview? Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2016-09-15 15:02 +0000
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-13 10:06 +0100
                Re: How would you prepare for javascripting interview? John Harris <niam@jghnorth.org.uk.invalid> - 2016-09-06 19:53 +0100
    Re: How would you prepare for javascripting interview? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-18 22:30 +0200
  Re: How would you prepare for javascripting interview? justaguy <lichunshen84@gmail.com> - 2016-07-18 14:56 -0700
  Re: How would you prepare for javascripting interview? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-07-19 16:01 -0300
    Re: How would you prepare for javascripting interview? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2016-07-19 16:16 -0300

csiph-web