Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 1.17 KB

readme.md

File metadata and controls

28 lines (20 loc) · 1.17 KB

go-seqs

go-seqs is a library for working with sequence-like data in Go, taking advantage of generics introduced in Go 1.18.

Usage

Add the library as a dependency:

go get github.com/siliconbrain/go-seqs

Import it into your code:

import "github.com/siliconbrain/go-seqs/seqs"

Use to your heart's delight!

Comparision with iter

The iter package defines Seq as

type Seq[V any] func(yield func(V) bool)

which unfortunately means no non-trivial methods can be defined on implementations. Meanwhile, implementations of our seqs.Seq interface can also implement any other interface, e.g. optional length queries via seqs.Lener/seqs.FiniteSeq.

Unfortunately, seqs.Seq is not directly compatible with iter.Seq since yield's return value's meaning is inverted.