itertools: github.com/yanatan16/itertools Index | Files

package itertools

import "github.com/yanatan16/itertools"

Package itertools provides a translation of the python standard library module itertools. Many of the functions have been brought over, althought not all. In this implementation, chan interface{} has been used as all iterators; if more specific types are necessary, feel free to copy the code to your project to be implemented with more specific types.

Index

Package Files

itertools.go

func List Uses

func List(it Iter) []interface{}

func Reduce Uses

func Reduce(it Iter, red Reducer, memo interface{}) interface{}

Reduce the iterator (aka fold) from the left

func Tee Uses

func Tee(it Iter, n int) []Iter

Split an iterator into n multiple iterators Requires memory to keep values for n iterators

type Iter Uses

type Iter chan interface{}

func Chain Uses

func Chain(its ...Iter) Iter

Chain together multiple iterators

func Count Uses

func Count(i int) Iter

Count from i to infinity

func Cycle Uses

func Cycle(it Iter) Iter

Cycle through an iterator infinitely (requires memory)

func DropWhile Uses

func DropWhile(pred Predicate, it Iter) Iter

Elements after pred(el) == true

func Filter Uses

func Filter(pred Predicate, it Iter) Iter

Filter out any elements where pred(el) == false

func FilterFalse Uses

func FilterFalse(pred Predicate, it Iter) Iter

Filter out any elements where pred(el) == true

func Float32 Uses

func Float32(els ...float32) Iter

func Float64 Uses

func Float64(els ...float64) Iter

func Int32 Uses

func Int32(els ...int32) Iter

func Int64 Uses

func Int64(els ...int64) Iter

func Map Uses

func Map(fn Mapper, it Iter) Iter

Map an iterator to fn(el) for el in it

func MultiMap Uses

func MultiMap(fn MultiMapper, its ...Iter) Iter

Map p, q, ... to fn(pEl, qEl, ...) Breaks on first closed channel

func MultiMapLongest Uses

func MultiMapLongest(fn MultiMapper, its ...Iter) Iter

Map p, q, ... to fn(pEl, qEl, ...) Breaks on last closed channel

func New Uses

func New(els ...interface{}) Iter

func Repeat Uses

func Repeat(el interface{}, n ...int) Iter

Repeat an element n times or infinitely

func Slice Uses

func Slice(it Iter, startstopstep ...int) Iter

Sub-iterator from start (inclusive) to [stop (exclusive) every [step (default 1)]]

func Starmap Uses

func Starmap(fn MultiMapper, it Iter) Iter

Map an iterator if arrays to a fn(els...) Iter must be an iterator of []interface{} (possibly created by Zip) If not, Starmap will act like MultiMap with a single iterator

func TakeWhile Uses

func TakeWhile(pred Predicate, it Iter) Iter

Elements before pred(el) == false

func Tee2 Uses

func Tee2(it Iter) (Iter, Iter)

Helper to tee just into two iterators

func Uint Uses

func Uint(els ...uint) Iter

func Uint32 Uses

func Uint32(els ...uint32) Iter

func Uint64 Uses

func Uint64(els ...uint64) Iter

func Zip Uses

func Zip(its ...Iter) Iter

Zip up multiple interators into one Close on shortest iterator

func ZipLongest Uses

func ZipLongest(its ...Iter) Iter

Zip up multiple iterators into one Close on longest iterator

type Mapper Uses

type Mapper func(interface{}) interface{}

type MultiMapper Uses

type MultiMapper func(...interface{}) interface{}

type Predicate Uses

type Predicate func(interface{}) bool

type Reducer Uses

type Reducer func(memo interface{}, element interface{}) interface{}

Package itertools imports 1 packages (graph). Updated 2017-06-12. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).