-
Notifications
You must be signed in to change notification settings - Fork 4
/
gmap.sml
executable file
·30 lines (19 loc) · 707 Bytes
/
gmap.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(*======================================================================
A trivial list-based implementation of simple dictionaries. Used with/for
very small dictionaries.
=======================================================================*)
structure GMap:GMAP =
struct
type ('d,'r) map = ('d * 'r) list
val empty = []
fun lookUp(el,m,eq) =
let fun look(d,[]) = NONE
| look(d,(d1,r1)::rest) = if (eq(d,d1)) then SOME(r1) else look(d,rest)
in
look(el,m)
end
fun augment(m,(d,r)) = (d,r)::m
fun augmentLst(map,new_bindings) = new_bindings@map
fun join(old_map,new_map) = new_map@old_map
fun make(bindings) = bindings
end (** of structure GMap **)