Add new acceptance test scenario: 034
```
Error:
× Main thread panicked.
├─▶ at /Users/ktorz/Documents/Projects/aiken-lang/aiken/crates/aiken-project/src/lib.rs:670:22
╰─▶ called `Result::unwrap()` on an `Err` value: FreeUnique(Name { text: "aiken/list_foldr_list_data_data_list_data", unique: Unique(1) })
```
This commit is contained in:
18
examples/acceptance_tests/034/lib/tests.ak
Normal file
18
examples/acceptance_tests/034/lib/tests.ak
Normal file
@@ -0,0 +1,18 @@
|
||||
pub fn foldr(self: List<a>, with: fn(a, b) -> b, zero: b) -> b {
|
||||
when self is {
|
||||
[] -> zero
|
||||
[x, ..xs] -> with(x, foldr(xs, with, zero))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flat_map(self: List<a>, with: fn(a) -> List<b>) -> List<b> {
|
||||
foldr(self, fn(x, xs) { concat(with(x), xs) }, [])
|
||||
}
|
||||
|
||||
test flat_map_1() {
|
||||
flat_map([], fn(a) { [a] }) == []
|
||||
}
|
||||
|
||||
test flat_map_2() {
|
||||
flat_map([1, 2, 3], fn(a) { [a, a] }) == [1, 1, 2, 2, 3, 3]
|
||||
}
|
||||
Reference in New Issue
Block a user