News for hackers. Stuff that matters.
Re:LINQ Ruined My Favorite Interview Question by untog on Thursday July 11, 2013 @10:46AM (#6026324)
I almost feel a bit gross when I have to write a "foreach" loop at this point

Agreed. I've transitioned to spending most of my time in JS, and wherever I can I use .map(), but the chaining it's not quite the same as LINQ. Someday I intend to write a library of Array addons to provide GroupBy and so on, but I can't imagine it'll be super efficient.

Re:LINQ Ruined My Favorite Interview Question by PaulAJ on Thursday July 11, 2013 @02:18PM (#6027964)
This is the problem with doing functional list stuff in languages that permit side effects: the order of execution for each function has to be strictly defined (in both senses of the word), so the compiler can't optimise the code. In Haskell the solution (see my comment on the original page) would probably (I haven't actually checked the GHC core output) be folded into a single loop.
Re:LINQ Ruined My Favorite Interview Question by aaronm67 on Thursday July 11, 2013 @05:10PM (#6029252)
In Underscore, you can do something like:

    _([ ... ]).map( ... ).filter( ... ).value()
It's not exactly extending the native array...but there are far fewer side effects to doing it this way.
Re:LINQ Ruined My Favorite Interview Question by WickyNilliams on Friday July 12, 2013 @06:59AM (#6031947)
The problem with this is that it's doing multiple iterations. LINQ on the other hand builds up an expression tree that is "compiled" into a single loop when `ToList()` (or some other method which gets the results) is eventually called.
Re:LINQ Ruined My Favorite Interview Question by alevans4 on Thursday July 11, 2013 @11:18AM (#6026547)
Underscore has groupBy and some of the others you may be looking for.
Re:LINQ Ruined My Favorite Interview Question by untog on Thursday July 11, 2013 @11:19AM (#6026560)
Yes.. I do understand why extending the base Array object in JS is deeply frowned upon but at the same time I often wish that these sort of extensions were on the Array object. It feels clunky to use them otherwise.
Re:LINQ Ruined My Favorite Interview Question by buu700 on Thursday July 11, 2013 @02:09PM (#6027873)
You should check out Sugar, by far my favourite standard JS lib to use in any complex project: http://sugarjs.com/
Re:LINQ Ruined My Favorite Interview Question by WickyNilliams on Friday July 12, 2013 @06:50AM (#6031925)
This may be what you're looking for. I think it was developed my MS specifically for this reason:

https://github.com/Reactive-Extensions/RxJS