|
definition: |
delete' :: String -> InternalTrie a -> Maybe (InternalTrie a)
delete' k (InternalTrie v ts) = do
res <- case k of
[] -> v *> Just (InternalTrie Nothing ts)
(c:cs) -> do
t <- Prelude.lookup c ts
t' <- delete' cs t
let e = (c, t')
es = filter ((/= c) . fst) ts
return $ InternalTrie v (if null' t then es else e : es)
return $ sanitize res
where
sanitize :: InternalTrie a -> InternalTrie a
sanitize (InternalTrie v' ts') =
InternalTrie v' (filter (not . null' . snd) ts')
|
|
demand: |
arguments 1 2 |
|
deterministic: |
deterministic operation |
|
documentation: |
Tries to delete a key from the internal trie. If the key is not in the trie, `Nothing` is returned. This feedback is used to determine whether the size of the trie has changed. |
|
failfree: |
(_, _) |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{InternalTrie}) |-> _}
|
|
name: |
delete' |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> InternalTrie a -> Prelude.Maybe (InternalTrie a) |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |