1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-17 00:07:49 +02:00

fix: introduce stateless iterator

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-07-24 16:43:07 +02:00
parent 8c58e8d760
commit 1713de0c3e
51 changed files with 2076 additions and 25 deletions

View File

@ -144,7 +144,7 @@ func Append[A any](as []A, a A) []A {
}
func IsEmpty[A any](as []A) bool {
return array.IsEmpty(as)
return G.IsEmpty(as)
}
func IsNonEmpty[A any](as []A) bool {
@ -181,12 +181,11 @@ func Ap[B, A any](fa []A) func([]func(A) B) []B {
}
func Match[A, B any](onEmpty func() B, onNonEmpty func([]A) B) func([]A) B {
return func(as []A) B {
if IsEmpty(as) {
return onEmpty()
}
return onNonEmpty(as)
}
return G.Match[[]A](onEmpty, onNonEmpty)
}
func MatchLeft[A, B any](onEmpty func() B, onNonEmpty func(A, []A) B) func([]A) B {
return G.MatchLeft[[]A](onEmpty, onNonEmpty)
}
func Tail[A any](as []A) O.Option[[]A] {