-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.scala
54 lines (48 loc) · 1.08 KB
/
Main.scala
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
53
54
//Class Demo
//CS345H Jan Rellermeyer
//12-3-14
object Main extends ScIntr {
def main(args: Array[String]):Unit = {
try{
/*canceling and aliasing*/
DEFINE ("mi" := "kilo-ampheres" ^ 3)
DEFINE ("hotdog" := "mi*moles")
'a := 10 ("hotdog")
'p := 1 ("1/moles*kilo-ampheres")
's := 'a * 'p
PRINT('s)
'b := 5 ("mi*candelas*moles*moles")
PRINT('b)
'd := 1 ("kilo-ampheres*moles")
'c := 'b / 'd
PRINT('c)
/*right associativity*/
DEFINE("oz" := "grams" SCALE 28)
'a := 3("oz")
'b := 56("grams")
'c := 'a + 'b
'd := 'b + 'a
PRINT('c)
PRINT('d)
'c TO "grams"
PRINT('c)
/*compatibility checks*/
DEFINE("mi" := "kilo-meters" SCALE 1.6)
'a := 16 ("kilo-meters")
'b := 10 ("mi")
'c := 12 ("mi")
println('a =:= 'b)
println('a === 'b)
println('c === 'b)
println('c =:= 'b)
println('c =:= "kilo-meters")
/*error checking*/
'a := 2 ("oz")
'b := 5 ("mi")
'c := 'a + 'b
}
catch{
case ex:SciException => println(ex.getMessage())
}
}
}