Skip to content

Instantly share code, notes, and snippets.

@YoEight
Created February 27, 2014 20:54
Show Gist options
  • Select an option

  • Save YoEight/9259329 to your computer and use it in GitHub Desktop.

Select an option

Save YoEight/9259329 to your computer and use it in GitHub Desktop.
My answer to http://codepad.org/McxPLp1l exercise
import Data.Functor.Foldable
divIfMultiple :: Integral a => a -> [a] -> Maybe [a]
divIfMultiple x = cata go
where
go Nil = Just []
go (Cons a r)
| mod a x == 0 = fmap (div a x:) r
| otherwise = Nothing
recursion-schemes == 4.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment