equal
deleted
inserted
replaced
|
1 def even(n: Int) : Boolean = { |
|
2 if (n == 0) true else odd(n - 1) |
|
3 } |
|
4 def odd(n: Int) : Boolean = { |
|
5 if (n == 0) false else even(n - 1) |
|
6 } |
|
7 |
|
8 |
|
9 |
|
10 |
1 // A Small Compiler for a Simple Functional Language |
11 // A Small Compiler for a Simple Functional Language |
2 // (includes a parser and lexer) |
12 // (includes a parser and lexer) |
3 // |
13 // |
4 // call with |
14 // call with |
5 // |
15 // |
14 // |
24 // |
15 // amm fun.sc run defs.fun |
25 // amm fun.sc run defs.fun |
16 // amm fun.sc run fact.fun |
26 // amm fun.sc run fact.fun |
17 // |
27 // |
18 // the first prints out the JVM instructions for two |
28 // the first prints out the JVM instructions for two |
19 // factorial functions |
29 // factorial functions; the next compiles/runs fun files |
20 // |
|
21 // the next compile/run fun files |
|
22 // |
30 // |
23 |
31 |
24 import $file.fun_tokens, fun_tokens._ |
32 import $file.fun_tokens, fun_tokens._ |
25 import $file.fun_parser, fun_parser._ |
33 import $file.fun_parser, fun_parser._ |
26 |
34 |