3 ms·
It's basically the same thing, except with that syntax, you have to label all the intermediate results
by acjohnson55 12y ago
It's basically the same thing, except with that syntax, you have to label all the intermediate results
- bbcbasic 12y agoTo avoid labeling: routine :: Int -> Maybe Int routine n = Just n >>= (divisorFilter 3) >>= (divisorFilter 2) >>= (divisorFilter 5) -- Supporting function divisorFilter :: Int -> Int -> Maybe Int divisorFilter d n | n `mod` d == 0 = Just n | otherwise = Nothing -- Using do syntax routine' :: Int -> Maybe Int routine' n = do first <- divisorFilter 3 n second <- divisorFilter 2 first divisorFilter 5 second