This file contains 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
collatz :: Integer -> Maybe Integer | |
collatz n | |
| n < 1 = Nothing | |
| n == 1 = Just 0 | |
| even n = fmap (+ 1) $ collatz (n `div` 2) | |
| odd n = fmap (+ 1) $ collatz (3 * n + 1) |
This file contains 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
Pattern match(es) are non-exhaustive | |
In an equation for ‘collatz’: | |
Patterns not matched: | |
GHC.Num.Integer.IS _ | |
GHC.Num.Integer.IP _ | |
GHC.Num.Integer.IN _ |
This file contains 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
name: collatz-conjecture | |
version: 1.2.1.4 | |
dependencies: | |
- base | |
library: | |
exposed-modules: CollatzConjecture | |
source-dirs: src | |
ghc-options: -Wall | |
# dependencies: | |
# - foo # List here the packages you | |
# - bar # want to use in your solution. | |
tests: | |
test: | |
main: Tests.hs | |
source-dirs: test | |
dependencies: | |
- collatz-conjecture | |
- hspec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment