Update generic syntax in tests.
This commit is contained in:
parent
8f69a4b600
commit
572121974e
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue