structure Util :> UTIL = struct datatype 'a flat_element = BEGIN | END | ITEM of 'a type 'a flat_tree = 'a flat_element list fun printInt n = Web.print (if n < 0 then "-" ^ Int.toString (~n) else Int.toString n) fun printReal n = Web.print (if n < 0.0 then "-" ^ Real.fmt (StringCvt.FIX (SOME 2)) (~n) else Real.fmt (StringCvt.FIX (SOME 2)) n) fun id x = x fun makeSet f items = case items of [] => "()" | [usr] => "(" ^ f usr ^ ")" | usr::rest => foldl (fn (usr, s) => s ^ ", " ^ f usr) ("(" ^ f usr) rest ^ ")" fun neg (r : real) = ~r fun isIdent ch = Char.isLower ch orelse Char.isDigit ch fun validHost s = size s > 0 andalso size s < 20 andalso List.all isIdent (String.explode s) fun validDomain s = size s > 0 andalso size s < 100 andalso List.all validHost (String.fields (fn ch => ch = #".") s) fun whoisUrl dom = String.concat ["http://reports.internic.net/cgi/whois?whois_nic=", dom, "&type=domain"] end