1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: fix goline error

This commit is contained in:
dudaodong
2023-03-01 11:10:12 +08:00
parent 66efe61834
commit 081908bce3
6 changed files with 31 additions and 20 deletions

View File

@@ -64,6 +64,7 @@ func Generate[T any](generator func() func() (item T, ok bool)) stream[T] {
var zeroValue T
for next, item, ok := generator(), zeroValue, true; ok; {
item, ok = next()
if ok {
source = append(source, item)
@@ -98,7 +99,7 @@ func FromRange[T constraints.Integer | constraints.Float](start, end, step T) st
}
l := int((end-start)/step) + 1
source := make([]T, l, l)
source := make([]T, l)
for i := 0; i < l; i++ {
source[i] = start + (T(i) * step)
@@ -160,7 +161,7 @@ func (s stream[T]) Filter(predicate func(item T) bool) stream[T] {
// Map returns a stream consisting of the elements of this stream that apply the given function to elements of stream.
func (s stream[T]) Map(mapper func(item T) T) stream[T] {
source := make([]T, s.Count(), s.Count())
source := make([]T, s.Count())
for i, v := range s.source {
source[i] = mapper(v)