|
|
1.1 root 1: (* Standard environment, as defined in Definition of SML, Version 2 *)
2:
3: structure Standard =
4: struct
5:
6: infix 7 * / div mod
7: infix 6 + - ^
8: infixr 5 :: @
9: infix 4 = <> < > <= >=
10: infix 3 o :=
11:
12: val ! = Ref.!
13: val op := = Ref.:=
14: val not = Bool.not
15: val floor = Real.floor
16: val truncate = Real.truncate
17: val ceiling = Real.ceiling
18: val real = Real.real
19: val sin = Real.sin and cos = Real.cos
20: and sqrt = Real.sqrt and arctan = Real.arctan
21: and exp = Real.exp and ln = Real.ln
22: and rev = List.rev and map = List.map and op @ = List.@
23: exception Floor=Real.Floor and Sqrt=Real.Sqrt
24: exception Exp=Real.Exp and Ln=Real.Ln
25: val op / = Real./
26:
27: exception Mod
28: exception Quot
29: exception Prod
30: exception Sum
31: exception Diff
32: exception Chr = String.Chr and Ord = String.Ord
33: exception Div = Integer.Div
34:
35: val op + = fn (a,b) => Integer.+(a,b) handle Integer.Overflow => raise Sum
36: val op * = fn (a,b) => Integer.*(a,b) handle Integer.Overflow => raise Prod
37: val op div = fn (a,b) =>
38: (if Integer.>=(a,0)
39: then if Integer.>=(b,0)
40: then Integer.div(a,b)
41: else Integer.-(Integer.div(Integer.-(a,1),b),1)
42: else if Integer.>=(b,0)
43: then Integer.-(Integer.div(Integer.+(a,1),b),1)
44: else Integer.div(a,b)) handle Integer.Overflow => raise Div
45: val op - = fn (a,b) => Integer.-(a,b) handle Integer.Overflow => raise Diff
46: val op mod = fn (a,b) => Integer.-(a,Integer.*(a div b,b))
47: handle Div => raise Mod
48: | Integer.Overflow => raise Mod
49: structure BasicIO : BASICIO = IO
50: open BasicIO
51: val output = fn (f,s) => output f s
52: val input = fn (f,i) => input f i
53: val size = String.size
54: val explode = String.explode and implode = String.implode
55: val op ^ = String.^
56: val chr = String.chr and ord = String.ord
57:
58: val op o = General.o and op = = General.= and op <> = General.<>
59: exception Bind= General.Bind and Match = General.Match
60: exception Interrupt = General.Interrupt
61: end (* structure Standard *)
62:
63: structure Standard =
64: struct
65: open Standard
66: overload ~ : ('a->'a) as Integer.~ and Real.~
67: overload + : ('a*'a -> 'a) as Standard.+ and Real.+
68: overload - : ('a*'a -> 'a) as Standard.- and Real.-
69: overload * : ('a*'a -> 'a) as Standard.* and Real.*
70: overload < : ('a*'a -> bool) as Integer.< and Real.<
71: overload > : ('a*'a -> bool) as Integer.> and Real.>
72: overload <= : ('a*'a -> bool) as Integer.<= and Real.<=
73: overload >= : ('a*'a -> bool) as Integer.>= and Real.>=
74: overload abs : ('a->'a) as Integer.abs and Real.abs
75:
76: end (* structure Environ *)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.