News for hackers. Stuff that matters.
Re:What Compsci textbooks don't tell you: Real world code sucks by mifrai on Saturday December 22, 2012 @04:52PM (#4957602)
Honestly, I don't think danidiaz was trying to be clever so much as not knowing about the existence of filterM. A good chunk of the code was just an implementation of it:

    filterM' f xs = map fst . filter snd . zip xs <$> mapM f xs
So, given filterM, the code would have looked like

    nexist n xs = take n <$> filterM (fmap not . doesFileExist) xs
Which doesn't look clever at all and it's fairly easy to understand.
Re:What Compsci textbooks don't tell you: Real world code sucks by danidiaz on Sunday December 23, 2012 @04:21AM (#4959054)
Yeah, I had forgotten about filterM.

By the way, I like the (fmap not . doesFileExist) bit. It´s cleaner and less cluttered than (\f -> doesFileExist f >>= return . not)

Re:What Compsci textbooks don't tell you: Real world code sucks by Maro on Sunday December 23, 2012 @03:41AM (#4958993)
Cool, thanks!