Sequences
Arrays
Data Types
module Collatz where collatz :: Int -> [Int] collatz = iterate next where next n | even n = n `div` 2 | odd n = n * 3 + 1
- module Collatz where
- collatz :: Int -> [Int]
collatz n = n : collatz nextwhere next | even n = n `div` 2| odd n = n * 3 + 1- collatz = iterate next
- where next n | even n = n `div` 2
- | odd n = n * 3 + 1