Skip to content

A library for working with sequence-like data in Go

License

Notifications You must be signed in to change notification settings

siliconbrain/go-seqs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A library for working with sequence-like data in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages