Last active
July 14, 2016 15:42
-
-
Save jan-matejka/1e8ffa4ed05dd3c70454e61ce3a361ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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