Baseline: tree as shared
This commit is contained in:
1679 files changed
+1024562
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# probe: a function as a compile-time parameter, f: def(Int) thin -> Int in brackets (the manual's inplace_transform), with a named function and a lambda that captures nothing
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: [-3, -1, -4]
|
||||
# expect-stdout: [9, 1, 16]
|
||||
def map_in_place[f: def(Int) thin -> Int](mut xs: List[Int]):
|
||||
for i in range(len(xs)):
|
||||
xs[i] = f(xs[i])
|
||||
|
||||
|
||||
def negate(x: Int) -> Int:
|
||||
return -x
|
||||
|
||||
|
||||
def main():
|
||||
var xs: List[Int] = [3, 1, 4]
|
||||
map_in_place[negate](xs)
|
||||
print(xs)
|
||||
map_in_place[lambda (x: Int) -> Int: x * x](xs)
|
||||
print(xs)
|
||||
Reference in new issue
Block a user