Hacker News new | ask | show | jobs
by bryanrasmussen 1584 days ago
I believe it was gotten from the ambiguities of English - when you say "all most programmers need is " it could mean all that is needed most of the time but probably the more usual meaning would be that a great number of programmers (most programmers - greater than 50% of programmers), will never need anything but `map` or `reduce`. If the second meaning is taken then this means as a corollary that these developers never need to be able to break or continue in a loop.

Of course if it were assumed they never need anything but the higher level methods: map, reduce, some, every etc. - then they would probably use some or every if they wanted to break.

2 comments

out of the edit window, evidently was typing quickly, but would not use every for implementing a break like functionality on an array - some could do it in some instances or maybe find.

I suppose filter could maybe be hacked to do it in some cases dependent on implementation, if the implementation determined that it was impossible to ever return true for any of the items remaining in an array that implementation might effectively break the array processing however every way I can think of doing that would be artificial, horrible, and probably full of side effects.

> this means as a corollary that these developers never need to be able to break or continue in a loop.

No it doesn’t.

I don't understand this no it doesn't, the logic I outlined can be boiled down to

If I only need to do X

And X cannot do Y

Then I do not need to do Y

-----------------------------

If I need to do Y

And X cannot do Y

Then I need to do something other than X

-------------------------

Give your answer of no it doesn't please be so kind as to outline the logical reasoning that you are envisioning?

on edit: added line between logical statements.

Unless I've misunderstood you, you said that, for example, `continue` cannot be implemented in terms of `map`, which simply isn't true. It's trivial.
I thought the original statement was break or continue, I was actually focusing on break? As far as I know you don't break in map, you can return null but not break the loop itself.

on edit: although I almost never break in a loop, I use some other construct instead.

on second edit: maybe I should say iteration instead of loop but will let it stand.

It's not clear to me what you're trying to achieve. Sorry.