Update generic syntax in tests.

This commit is contained in:
KtorZ 2022-12-13 11:23:51 +01:00
parent 8f69a4b600
commit 572121974e
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
4 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
pub fn length(xs: List(a)) -> Int {
pub fn length(xs: List<a>) -> Int {
when xs is {
[] -> 0
[_, ..rest] -> 1 + length(rest)

View File

@ -1,4 +1,4 @@
pub fn repeat(x: a, n: Int) -> List(a) {
pub fn repeat(x: a, n: Int) -> List<a> {
if n <= 0 {
[]
} else {

View File

@ -1,11 +1,11 @@
pub fn foldr(xs: List(a), f: fn(a, b) -> b, zero: b) -> b {
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 concat(left: List(a), right: List(a)) -> List(a) {
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
foldr(left, fn(x, xs) { [x, ..xs] }, right)
}

View File

@ -1,15 +1,15 @@
pub fn foldr(xs: List(a), f: fn(a, b) -> b, zero: b) -> b {
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 prepend(x: a, xs: List(a)) -> List(a) {
pub fn prepend(x: a, xs: List<a>) -> List<a> {
[x, ..xs]
}
pub fn concat(left: List(a), right: List(a)) -> List(a) {
pub fn concat(left: List<a>, right: List<a>) -> List<a> {
foldr(left, prepend, right)
}