seq

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accumulate

func Accumulate[A, Value any](seq iter.Seq[Value], acc func(Value, A) A) A

Accumulate passes sequence values through the accumulator function and returns the accumulated value.

func ChanAsSeq

func ChanAsSeq[Value any](ch <-chan Value) iter.Seq[Value]

ChanAsSeq converts a <-channel to a sequence.

func Filter

func Filter[Value any](seq iter.Seq[Value], f func(Value) bool) iter.Seq[Value]

Filter returns a sequence with the values for which f returns true.

func Generate

func Generate[Value any](generator func() Value) iter.Seq[Value]

Generate a sequence by calling the passed generator function.

func Generator

func Generator[Value, Context any](c Context, f func(Context) Value) func() Value

Generator makes a generator providing context to the given function.

func Index

func Index[I ~int | ~uint](i I) func() I

Index returns a sequence index generator function.

Example
package main

import (
	"fmt"
	"slices"

	"github.com/parametalol/curry/seq"
)

func main() {
	fmt.Println(slices.Collect(
		seq.Take(5,
			seq.Generate(seq.Index(5)))))
}
Output:

[5 6 7 8 9]

func Last

func Last[Value any](seq iter.Seq[Value]) (result Value)

Last consumes the sequence and returns the last value.

func Map

func Map[ValueIn, ValueOut any](seq iter.Seq[ValueIn], f func(ValueIn) ValueOut) iter.Seq[ValueOut]

Map translates sequence values with the provided function.

func Map15

func Map15[K, V, Value any](seq iter.Seq2[K, V], f func(K, V) Value) iter.Seq[Value]

Map15 translates key-value sequence to a single value sequence with the provided function.

func Map2

func Map2[KeyIn, ValueIn, KeyOut, ValueOut any](seq iter.Seq2[KeyIn, ValueIn], f func(KeyIn, ValueIn) (KeyOut, ValueOut)) iter.Seq2[KeyOut, ValueOut]

Map2 translates one key-value sequence to another with the provided function.

func Range

func Range(begin, end, step int) iter.Seq[int]

Range generates a sequnce of integer between the given begin and end, with given the step.

func SeqAsChan

func SeqAsChan[Value any](seq iter.Seq[Value]) <-chan Value

SeqAsChan converts a sequence to a <-channel.

func Tail

func Tail[Value any](seq iter.Seq[Value]) (Value, bool, iter.Seq[Value])

Tail reads the first value from the sequence, returns whether it managed to get it, and the iterator to the rest of the sequence.

func Take

func Take[Value any](n uint, seq iter.Seq[Value]) iter.Seq[Value]

Take first n values from the sequence.

func Until

func Until[Value any](seq iter.Seq[Value], f func(Value) bool) iter.Seq[Value]

Until passes values from the sequence until f returns true.

func Zip

func Zip[A, B any](a iter.Seq[A], b iter.Seq[B]) iter.Seq2[A, B]

func ZipShort

func ZipShort[A, B any](a iter.Seq[A], b iter.Seq[B]) iter.Seq2[A, B]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL