Cleanup combination accessing code
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module SimpleTrie where
|
||||
import Data.Map
|
||||
import Data.Map.Strict
|
||||
import Control.Lens
|
||||
data Trie a b = Trie
|
||||
{ _trieMVal :: Maybe b
|
||||
@@ -22,5 +22,5 @@ insertInTrie (k:ks) x = trieChildren %~ insertWith f k (singletonTrie ks x)
|
||||
f _ = insertInTrie ks x
|
||||
|
||||
lookupTrie :: Ord a => [a] -> Trie a b -> Maybe b
|
||||
lookupTrie [] t = _trieMVal t
|
||||
lookupTrie (k:ks) t = _trieChildren t !? k >>= lookupTrie ks
|
||||
lookupTrie [] t = _trieMVal t
|
||||
|
||||
Reference in New Issue
Block a user