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

Haskell list comprehensions

Name: Anonymous 2009-05-11 0:44

Is there something deeper to it, or is it just a shitty excuse for not writing, e.g. three for loops in [(a, b, c) | a <- [1..10], b <- [1..10], c <- [1..10], a^2 + b^2 == c^2]
and it still being O(n3)?

Name: Anonymous 2009-05-12 7:48

filter (liftA2 (==) (uncurry ((+) `on` (^2)).fst) ((^2).snd)) $ (join $ join $ liftA3 (((,).).(,))) [1..10]

alternatively

filter (uncurry (==) . (uncurry ((+) `on` (^2)) *** (^2))) $ (join $ join $ liftA3 (((,).).(,))) [1..10]

Hand-crafted pointless style is superior. Please, do suggest improvements. (Maybe some parens can be removed... I don't have a compiler handy to test, though.)

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