Geography database
[hcoop/zz_old/portal.git] / util.sml
1 structure Util :> UTIL =
2 struct
3
4 datatype 'a flat_element =
5 BEGIN
6 | END
7 | ITEM of 'a
8 type 'a flat_tree = 'a flat_element list
9
10 fun printInt n =
11 Web.print (if n < 0 then
12 "-" ^ Int.toString (~n)
13 else
14 Int.toString n)
15
16 fun printReal n =
17 Web.print (if n < 0.0 then
18 "-" ^ Real.fmt (StringCvt.FIX (SOME 2)) (~n)
19 else
20 Real.fmt (StringCvt.FIX (SOME 2)) n)
21
22 fun id x = x
23
24 fun makeSet f items =
25 case items of
26 [] => "()"
27 | [usr] => "(" ^ f usr ^ ")"
28 | usr::rest => foldl (fn (usr, s) => s ^ ", " ^ f usr) ("(" ^ f usr) rest ^ ")"
29
30 fun neg (r : real) = ~r
31
32 end