>>23
Well, you would need a lot of memory to build a list that long, but once you have n primes, finding the next prime is of the order n log(n). The person above advocating the exponential algorithm clearly hasn't got a clue about programming.
Name:
Anonymous2007-04-15 21:33 ID:pr2p8hC+
>>23
Well, you would need a lot of memory to build a list that long, but once you have n primes, finding the next prime is of the order n log(n). The person above advocating the exponential algorithm clearly hasn't got a clue about programming.
>>7
`where` is not really considered to make a new line and if-then-else is like a function. If you are going to say someone just removed the new-lines then that line has to have a semi-colon in there somewhere.
Name:
Anonymous2007-05-15 14:06 ID:FfXQ49DI
>>37
I meant that in the pull-your-head-out-of-you-ass-and-realize-no-sane-person-really-writes-Haskell-like-that-because-it-would-be-completely-unreadable kind of way.
I really do wonder who trolled who this time, though.
Name:
Anonymous2007-05-15 14:53 ID:M2BoesvI
>>35
def isprime(n): return n > 1 and not any(n % d == 0 for d in xrange(2, n//2+1))
Name:
Anonymous2007-05-15 15:26 ID:ynCmddE9
if-then-else is like a function
This seems like a good time to bring up one of my pet peeves about Haskell. Why _isn't_ if a function? Observe: if :: Bool -> a -> a -> a
if True then _ = then
if False _ else = else
No ugly keywords fagging my shit up, and unlike if functions in other languages you don't have to worry about both then and else both being evaluated when they could potentially be computationally expensive - thanks to Haskell's laziness you're guaranteed only one will be.