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:
parent
722117bfc4
commit
77fbb3cbdb
|
@ -0,0 +1,5 @@
|
|||
# This file was generated by Aiken
|
||||
# You typically do not need to edit this file
|
||||
|
||||
requirements = []
|
||||
packages = []
|
|
@ -0,0 +1,2 @@
|
|||
name = "aiken-lang/acceptance_test_034"
|
||||
version = "0.0.0"
|
|
@ -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]
|
||||
}
|
Loading…
Reference in New Issue