Commit cd08864c authored by lj1019's avatar lj1019
Browse files

Add lambda tests

parent a9f3dd50
# Call lambdas repetitively
# Output:
# 0
# 1
# 2
# 3
# 4
# Program:
begin
int n = 5
int i = 0 ;
while i < n do
println call (\() -> i)() ;
i = i + 1;
done ;
end
# Assign to a variable ad print the result of the lambda
# Output:
# 6
# Program:
begin
int y = call (\(int x, int y) -> x * y)(2, 3);
print y
end
\ No newline at end of file
# Call lambda inside a function
# Output:
# 6
# Program:
begin
int f(int x, int y) is
return call (\(int x, int y) -> x * y)(x,y)
end
int y = f(2,3)
print y
end
\ No newline at end of file
# call lambdas repetitively
# Output:
# 5
# Program:
begin
print call (\(int x, int y, bool z, bool a, bool b, string c) -> x + y)(2, 3, false, false, true, "hello")
end
\ No newline at end of file
# a simple lambda is declared, but not called
# Output:
# #empty#
# Program:
begin
call (\(int x, int y) -> x * y)(2, 3)
skip
end
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