Add new acceptance test scenario (022)

```
  thread 'main' has overflowed its stack
  fatal runtime error: stack overflo
  ```
This commit is contained in:
KtorZ 2022-12-17 13:36:23 +01:00 committed by Lucas
parent 44d72c046e
commit a51808d549
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,2 @@
name = "acceptance_test_022"
version = "0.0.0"

View File

@ -0,0 +1,23 @@
pub fn foldr(xs: List<a>, f: fn(a, b) -> b, zero: b) -> b {
when xs is {
[] -> zero
[x, ..rest] -> f(x, foldr(rest, f, zero))
}
}
pub fn filter_map(xs: List<a>, f: fn(a) -> Option<b>) -> List<b> {
foldr(
xs,
fn(x, ys) {
when f(x) is {
None -> ys
Some(y) -> [y, ..ys]
}
},
[],
)
}
test filter_map_1() {
filter_map([], fn(_) { Some(42) }) == []
}