Functional map-like data structure with arbitrary length data as keys?

Take the very big key, reduce it to something very small, use that as an index into a structure hashmap on Hackage Johan Tibbel's talk on hash tree structures.

Take the very big key, reduce it to something very small, use that as an index into a structure. Hashmap on Hackage. Johan Tibbel's talk on hash tree structures.

Ah, you're right. I guess I was thinking about hash collisions for arbitrarily large data incorrectly. Thanks.

– gspr Apr 13 at 7:24.

If you have two long keys that are almost identical, a Map will compare them both from the beginning, but a trie will only compare the suffixes that haven't already been eliminated by previous comparisons (if you see what I mean). So a trie would be more time-efficient in that situation. Tries can be optimised in various ways, and you might also want to look at ternary trees.

Here's one: module ListMap where import Data. Map as M data ListMap k v = ListMap { ifEmpty :: Maybe v, ifFull :: Maybe k (ListMap k v) } empty :: ListMap k v empty = ListMap Nothing M. Empty singleton :: k -> v -> ListMap k v singleton v = ListMap.

Empty { ifEmpty = Just v } singleton (k:ks) v = ListMap. Empty { ifFull = M. Singleton k (ListMap.

Singleton ks v) } lookup :: Ord k => k -> ListMap k v -> Maybe v lookup lm = ifEmpty lm lookup (k:ks) lm = M. Lookup k (ifFull lm) >>= ListMap. Lookup ks insert :: Ord k => k -> v -> ListMap k v -> ListMap k v insert v lm = lm { ifEmpty = Just v } insert (k:ks) v lm = lm { ifFull = M.

Alter (Just . Insertion) k (ifFull lm) } where insertion = maybe (ListMap. Singleton ks v) (ListMap.

Insert ks v) It's essentially creating a prefix tree on the list elements so you only compare as far as necessary.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions