File: Test114.ML

package info (click to toggle)
polyml 5.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 40,616 kB
  • sloc: cpp: 44,142; ansic: 26,963; sh: 22,002; asm: 13,486; makefile: 602; exp: 525; python: 253; awk: 91
file content (26 lines) | stat: -rw-r--r-- 581 bytes parent folder | download | duplicates (5)
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
(* Cut down version of bug reported by Phil Clayton in SVN 1180. *)

structure RedBlackDict =
struct
    type 'a maplet = string * 'a

    datatype colour = Red | Black

    datatype 'a tree =
    	Node of 'a node
    |	Tip
    withtype 'a node = 'a tree * colour * 'a maplet * 'a tree;

    datatype 'a map = Map of {t : 'a tree, bh : int};

    fun min (Map {t, ...} : 'a map) : 'a maplet = (
    	let	fun leftmost (l, _, A, _) = case l of
    			Node n	=> leftmost n
    		|	Tip	=> A

    	in	case t of
    			Node n	=> leftmost n
    		|	Tip	=> raise Empty
    	end
    )
end;