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
import Data.Maybe | |
import Control.Monad (liftM) | |
import Data.List (isPrefixOf) | |
import qualified Data.Map as M | |
import qualified Data.Foldable as F | |
-- | Trie container data type | |
data Trie a = Trie { value :: Maybe a | |
, children :: M.Map Char (Trie a) } | |
deriving (Show) |
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
import Data.List | |
collatz :: Int -> Int | |
collatz 1 = 0 | |
collatz n | |
| odd n = force $ (collatz $! 3*n+1) + 1 | |
| even n = force $ (collatz $! div n 2) + 1 | |
force x = x `seq` x |
NewerOlder