Add missing function 'concat' in acceptance test 034.

This commit is contained in:
KtorZ 2022-12-29 12:13:29 +01:00
parent 4f83d4fa1b
commit 6f8d1698fe
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,10 @@ pub fn foldr(self: List<a>, with: fn(a, b) -> b, zero: b) -> b {
}
}
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
foldr(left, fn(x, xs) { [x, ..xs] }, right)
}
pub fn flat_map(self: List<a>, with: fn(a) -> List<b>) -> List<b> {
foldr(self, fn(x, xs) { concat(with(x), xs) }, [])
}