equal
deleted
inserted
replaced
265 l"\n$else_br" ++ |
265 l"\n$else_br" ++ |
266 compile_exp(e2) |
266 compile_exp(e2) |
267 } |
267 } |
268 } |
268 } |
269 |
269 |
270 |
270 print("%d\n", i) |
271 val prelude = """ |
271 val prelude = """ |
272 @.str = private constant [4 x i8] c"%d\0A\00" |
272 @.str = private constant [4 x i8] c"%d\0A\00" |
273 |
273 |
274 declare i32 @printf(i8*, ...) |
274 declare i32 @printf(i8*, ...) |
275 |
275 |
350 def factC(n: Int, ret: Int => Int) : Int = { |
350 def factC(n: Int, ret: Int => Int) : Int = { |
351 if (n == 0) ret(1) |
351 if (n == 0) ret(1) |
352 else factC(n - 1, x => ret(x * n)) |
352 else factC(n - 1, x => ret(x * n)) |
353 } |
353 } |
354 |
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 fibC(10, x => {println(s"Result: $x") ; 1}) |
|
360 |
|
361 |
|
362 */ |
355 factC(6, x => x) |
363 factC(6, x => x) |
356 factC(6, x => {println(s"The final Result is $x") ; 0}) |
364 factC(6, x => {println(s"The final Result is $x") ; 0}) |
357 factC(6, _ + 1) |
365 factC(6, _ + 1) |
358 |
366 |
|
367 def fib(n: Int) : Int = { |
|
368 if (n == 0 || n == 1) 1 |
|
369 else fib(n - 1) + fib(n - 2) |
|
370 } |
|
371 |
|
372 |
359 def fibC(n: Int, ret: Int => Int) : Int = { |
373 def fibC(n: Int, ret: Int => Int) : Int = { |
360 if (n == 0 || n == 1) ret(1) |
374 if (n == 0 || n == 1) ret(1) |
361 else fibC(n - 1, x => fibC(n - 2, y => ret(x + y))) |
375 else fibC(n - 1, x => fibC(n - 2, y => ret(x + y))) |
362 } |
376 } |
363 |
|
364 fibC(10, x => {println(s"Result: $x") ; 1}) |
|
365 |
|
366 |
|
367 */ |
|