Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

(´∀`) Prime numbers (,,゚Д゚)

Name: Anonymous 2007-04-15 11:11 ID:00E9fssW

|code]isPrime x = (filter (0 ==) (map (mod x) [2..x-1])) == [][/code]

Name: Anonymous 2007-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.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List