summaryrefslogtreecommitdiff
path: root/src/list_key_fn.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/list_key_fn.sml')
-rw-r--r--src/list_key_fn.sml14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/list_key_fn.sml b/src/list_key_fn.sml
new file mode 100644
index 00000000..ec2bd26f
--- /dev/null
+++ b/src/list_key_fn.sml
@@ -0,0 +1,14 @@
+functor ListKeyFn(K : ORD_KEY)
+ : ORD_KEY where type ord_key = K.ord_key list = struct
+
+type ord_key = K.ord_key list
+
+val rec compare =
+ fn ([], []) => EQUAL
+ | ([], _) => LESS
+ | (_, []) => GREATER
+ | (x::xs, y::ys) => case K.compare (x, y) of
+ EQUAL => compare (xs, ys)
+ | ord => ord
+
+end