-- Implementation of a mapping, a set of (key,value) pairs. -- Sergio Antoy -- Tue Jul 17 08:32:17 PDT 2001 -- updated Thu Jun 29 10:35:40 PDT 2017 -- The store is a list of pairs where the first element is the -- key and the second is the mapped value. -- The representation is a list. If an ordering were available for -- the keys, a more efficient tree representation would be possible. -- The initial store is an empty mapping. -- Getting a mapping fails if and only if the key is not in the store. -- Consider instead returning a default value, e.g., 0. -- The value of a key is obtained by instantiating an argument of the call. -- Setting a mapping either adds a (key,value) pair to the store -- or updates the value of a key already in the store. -- Setting a mapping always returns a new mapping. {-# OPTIONS_CYMAKE -F --pgmF=currypp --optF=defaultrules #-} init_store = [] get a b (_++[(a,b)]++_) = True set a b (x++[(a,_)]++y) = x++[(a,b)]++y set'default a b s = (a,b):s