-
Notifications
You must be signed in to change notification settings - Fork 0
/
sml_11.sml
52 lines (40 loc) · 1.14 KB
/
sml_11.sml
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
fun printInt (a:int) =
print(Int.toString(a)^" ");
fun printIntInf (a:IntInf.int) =
print(IntInf.toString(a)^" ");
fun printReal (a:real) =
print(Real.toString(a)^" ");
fun printString (a:string) =
print(a^" ");
fun getInt () =
Option.valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn);
fun getIntInf () =
Option.valOf (TextIO.scanStream (IntInf.scan StringCvt.DEC) TextIO.stdIn);
fun getReal () =
Option.valOf (TextIO.scanStream (Real.scan) TextIO.stdIn);
fun printIntTable ( [] ) = ()
| printIntTable ( x::xs ) =
let
val tmp = printInt(x)
in
printIntTable(xs)
end;
fun printIntInfTable ( [] ) = ()
| printIntInfTable ( x::xs ) =
let
val tmp = printIntInf(x)
in
printIntInfTable(xs)
end;
fun getIntTable ( 0 ) = []
| getIntTable ( N:int) = getInt()::getIntTable(N-1);
fun getIntInfTable ( 0 ) = []
| getIntInfTable ( N:int) = getIntInf()::getIntInfTable(N-1);
(*****Begin*****)
val m:int=getInt();
val s:(IntInf.int)list=getIntInfTable(m);
fun sum(s::sx:(IntInf.int)list,k:IntInf.int):IntInf.int=
if null(sx)=true then s*k
else sum(sx,s*k);
printIntInf(sum(s,1));
(*****End*****)