You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote this mutable version and a test for it, I'm sure a more flexible version can be made using mutate or maybe an immutable version will turn out
import Data.HashTable.Class
import qualified Data.HashTable.ST.Cuckoo as C
import Control.Monad.ST
--merge :: (HashTable h1, HashTable h2, Hashable a) => h1 s a b -> h2 s a b -> ST s ()
merge tbl1 tbl2 = do
l1 <- toList tbl1
mapM (uncurry (insert tbl2)) l1
return ()
testST = do
tbl1 <- C.new
insert tbl1 "a" True
insert tbl1 "b" True
tbl2 <- C.new
insert tbl2 "b" False
insert tbl2 "c" False
merge tbl1 tbl2
a <- Data.HashTable.Class.lookup tbl2 "a"
b <- Data.HashTable.Class.lookup tbl2 "b"
c <- Data.HashTable.Class.lookup tbl2 "c"
return (a, b, c)
test = runST testST
No description provided.
The text was updated successfully, but these errors were encountered: