Commit 7e035431 authored by 540KJ's avatar 540KJ
Browse files

[sm919][jlq19] Add tests for clojures

parent b58a101a
# a simple closure with closure function taking in many closure variables
# Output:
# 23
# Exit:
# 0
# Program:
begin
int{int} f(int x, int a, int b, int c, int d) is
return (\(int y) -> d + x + y + a + b + c)
end
int{int} x = call f(2, 1, 3, 10, 4);
int y = call x(3);
println y
end
\ No newline at end of file
# a simple closure with closure function that only uses lambdas
# Output:
# 208
# Exit:
# 0
# Program:
begin
int a1 = 2 ;
int{int, int} f1 = \(int c, int d) -> a1 + c + d ;
int{int, int} x = \(int a, int b) -> call f1 (2, 3) + a + b + a1 ;
int y = call x(100, 99) ;
println y
end
\ No newline at end of file
# a simple closure that uses a lambda to return a function pointer
# Output:
# 100
# Exit:
# 0
# Program:
begin
int g(int a) is
return a
end
int a1 = 2 ;
int{int}{int, int} f1 = \(int c, int d) -> g ;
int{int} x = call f1(a1, a1) ;
int y = call x(100) ;
println y
end
\ No newline at end of file
......@@ -28,9 +28,9 @@ begin
int f() is
int qq = call q() ;
# f = 2**q
int f = call power(2, qq) ;
return f
# f = 2**q ;
int g = call power(2, qq) ;
return g
end
# The implementation of the following functions are translated from the URI above.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment