Categorygithub.com/astonm/go-itertools
repositorypackage
0.1.2
Repository: https://github.com/astonm/go-itertools.git
Documentation: pkg.go.dev

# README

go-itertools - Python's itertools for Go iterators

tag Go Version License

astonm/go-itertools is a library styled on the Python itertools library which works using Go 1.23+ iterators.

By convention, all of the functions in this library return either iter.Seq or iter.Seq2. Almost all of the functions operate on iter.Seq as input. The most notable exception is for the combinatoric functions which take a slice, constraining their use to finite sequences.

Install

go get github.com/astonm/go-itertools

Usage

This package can be imported under its default name of itertools like so:

import "github.com/astonm/go-itertools"

Then use one of the helpers below, e.g.

counter := itertools.Count()
// 0, 1, 2, ...

If you are using a large number of library functions or are nesting calls, the lengthy itertools can be a bit much. When brevity is better than clarity, we recommend the short name it, i.e.

import it "github.com/astonm/go-itertools"

Then use like so:

cycle := it.Cycle(it.FromSlice([]int{1,2,3}))
// 1, 2, 3, 1, 2, 3, ...

Documentation

GoDoc: https://pkg.go.dev/github.com/astonm/go-itertools

License

Copyright 2024 Aston Motes.

This project is under MIT license.