Skip to content

Commit 8dac3b2

Browse files
committed
Add method chaining example to regression tests
1 parent 5a97d00 commit 8dac3b2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <vector>
2+
3+
add: (in v : _, in a : int) -> auto = {
4+
cv := v;
5+
for cv do :(inout e : _) = {
6+
e += a;
7+
}
8+
return cv;
9+
}
10+
11+
dbl: (in v : _) -> auto = {
12+
cv := v;
13+
for cv do :(inout e : _) = {
14+
e *= 2;
15+
}
16+
return cv;
17+
}
18+
19+
main: () -> int = {
20+
21+
v : std::vector<int> = (1,2,3,4,5,6,7,8,9,10);
22+
23+
for v.dbl().add(1).dbl() do :(in e : _) = {
24+
std::cout << e << ", ";
25+
}
26+
27+
std::cout << std::endl;
28+
}

0 commit comments

Comments
 (0)