Skip to content

Instantly share code, notes, and snippets.

@jan-matejka
Last active July 14, 2016 15:42
Show Gist options
  • Select an option

  • Save jan-matejka/1e8ffa4ed05dd3c70454e61ce3a361ee to your computer and use it in GitHub Desktop.

Select an option

Save jan-matejka/1e8ffa4ed05dd3c70454e61ce3a361ee to your computer and use it in GitHub Desktop.
{-# LANGUAGE FlexibleContexts #-}
-- V1:
-- divides x y = (==) 0 $ flip mod x y
-- V2:
--
-- divides :: Integral a => a -> a -> Bool
-- divides x y = cmp $ mod_ x y
-- where
-- cmp :: Integral a => a -> Bool
-- cmp x = (==) 0 x
--
-- mod_ :: Integral a => a -> a -> a
-- mod_ x y = flip mod x y
-- V3:
divides :: Integral a => a -> a -> Bool
divides x = cmp . mod_ x
where
cmp :: Integral a => a -> Bool
cmp x = (==) 0 x
mod_ :: Integral a => a -> a -> a
mod_ = flip mod
main = putStrLn $ show $ divides 3 6
-- main = putStrLn "fuuu"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment