Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Males, Sebastian
wacc_examples
Commits
a75a75c4
Commit
a75a75c4
authored
Mar 14, 2021
by
Males, Sebastian
Browse files
[jlq19] Add new tests for lambdas
parent
30cb68ce
Changes
7
Hide whitespace changes
Inline
Side-by-side
valid/function/lambdas/callLambdaInALoop.wacc
View file @
a75a75c4
...
...
@@ -13,7 +13,8 @@ begin
int n = 5 ;
int i = 0 ;
while i < n do
int r = call (\(int i) -> i)(i) ;
int{int} a = \(int i) -> i ;
int r = call a(i) ;
println r ;
i = i + 1
done
...
...
valid/function/lambdas/callSimpleLambda.wacc
View file @
a75a75c4
...
...
@@ -5,6 +5,7 @@
# Program:
begin
int y = call (\(int x, int y) -> x * y)(2, 3);
int{int, int} z = \(int x, int y) -> x * y ;
int y = call z(2, 3);
print y
end
\ No newline at end of file
valid/function/lambdas/lambdaInsideFunction.wacc
View file @
a75a75c4
...
...
@@ -6,7 +6,8 @@
# Program:
begin
int f(int x, int y) is
int r = call (\(int x, int y) -> x * y)(x,y);
int{int, int} q = \(int x, int y) -> x * y ;
int r = call q(x,y);
return r
end
int y = call f(2,3);
...
...
valid/function/lambdas/lambdaWithManyArgs.wacc
View file @
a75a75c4
...
...
@@ -6,6 +6,7 @@
# Program:
begin
int r = call (\(int x, int y, bool z, bool a, bool b, string c) -> x + y)(2, 3, false, false, true, "hello");
int{int, int, bool, bool, bool, string} q = \(int x, int y, bool z, bool a, bool b, string c) -> x + y ;
int r = call q(2, 3, false, false, true, "hello");
print r
end
\ No newline at end of file
valid/function/lambdas/nestedLambdas.wacc
0 → 100644
View file @
a75a75c4
# nested lambdas
# Output:
# 12
# Exit:
# 0
# Program:
begin
int{int{int}, int{int}, int} x = (\(int{int} z, int{int} a, int b) -> call z(b) + call a(b));
int y = call x(\(int x) -> x + 3, \(int x) -> x + 3, 3);
println y
end
\ No newline at end of file
valid/function/simple_functions/lambdaHigherOrderManyVars.wacc
0 → 100644
View file @
a75a75c4
# using lambdas with many vars as a higher-order function
# Output:
# 6
# Exit:
# 0
# Program:
begin
int{int} f(int{int, int, int} d) is
return d
end
int{int} x = call f(\(int x, int y, int z) -> x + y + z);
int y = call x(1,2,3);
println y
end
\ No newline at end of file
valid/function/simple_functions/lambdaHigherOrderSimple.wacc
0 → 100644
View file @
a75a75c4
# uses both lambdas and higher order functions
# Output:
# 7
# Exit:
# 0
# Program:
begin
int{int} f(int{int} d) is
return d
end
int{int} x = call f(\(int y) -> y);
int y = call x(7);
println y
end
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment