Commit a75a75c4 by Males, Sebastian

### [jlq19] Add new tests for lambdas

parent 30cb68ce
 ... ... @@ -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 ... ...
 ... ... @@ -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
 ... ... @@ -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); ... ...
 ... ... @@ -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
 # 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
 # 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
 # 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!