News for hackers. Stuff that matters.
Re:Notes on Haskell: What's Wrong with the For Loop by Dn_Ab on Tuesday March 08, 2011 @07:03PM (#2303155)
Java's younger cousin C# also has this with Select, Where and Aggregate. But sometimes the foreach and even the for loop actually makes more sense, in particular when dealing with very imperative algorithms or are not acting over a (full) sequence at all.

I'm usually only reading and not writing python but I think list comprehensions are more idiomatic. Based on some comments I've seen here I also kind of get the impression comprhensions are abused.

Re:Notes on Haskell: What's Wrong with the For Loop by Fargren on Tuesday March 08, 2011 @07:08PM (#2303164)
Well, if you don't want to work with the whole sequence, you can filter it. But yeah, in those cases and some others, the for loop may be more idiomatic and better performing.
Re:Notes on Haskell: What's Wrong with the For Loop by Dn_Ab on Tuesday March 08, 2011 @07:13PM (#2303178)
Yes I'm talking about being able to stop early for one example. Or if the thing you are dealing with is not actually a sequence for another.
Re:Notes on Haskell: What's Wrong with the For Loop by darklajid on Tuesday March 08, 2011 @07:45PM (#2303277)
The former can probably be solved for lots of cases by TakeWhile(), which evaluates before consuming more elements and could be used to replace "abort the loop" patterns.

The latter is a different thing..

1: http://msdn.microsoft.com/en-us/library/bb534804.aspx

Re:Notes on Haskell: What's Wrong with the For Loop by Stormbringer on Tuesday March 08, 2011 @08:15PM (#2303355)
"Java's younger cousin C#"

We prefer the terms:

"brother by a different mother"

or if they're being naughty:

"red headed step-child".

Re:Notes on Haskell: What's Wrong with the For Loop by genera on Tuesday March 08, 2011 @09:32PM (#2303546)
s/naughty/stupid