sh

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

package sh defines some short hand iterator adapters. sh only holds functions which only combine other elements in this module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cancellable

func Cancellable[V any](n int, ctx context.Context, seq iter.Seq[V]) iter.Seq[V]

Cancellable returns an iterator over seq but it also checks if ctx is cancelled each n elements seq yields.

func Cancellable2

func Cancellable2[K, V any](n int, ctx context.Context, seq iter.Seq2[K, V]) iter.Seq2[K, V]

Cancellable2 returns an iterator over seq but it also checks if ctx is cancelled each n elements seq yields.

func Clone

func Clone[S ~[]E, E any](seq iter.Seq[S]) iter.Seq[S]

Clone maps seq by slices.Clone.

func Clone2

func Clone2[S1 ~[]E1, S2 ~[]E2, E1, E2 any](seq iter.Seq2[S1, S2]) iter.Seq2[S1, S2]

Clone2 maps seq by slices.Clone.

func Collect

func Collect[V any](seq iter.Seq[iter.Seq[V]]) iter.Seq[[]V]

Collect maps seq by slices.Collect.

func Collect2

func Collect2[K, V any](seq iter.Seq2[iter.Seq[K], iter.Seq[V]]) iter.Seq2[[]K, []V]

Collect2 maps seq by slices.Collect.

func HandleErr

func HandleErr[V any](handle func(V, error) bool, seq iter.Seq2[V, error]) iter.Seq[V]

HandleErr returns an iterator over only former value of seq. If latter value the seq yields is non-nil then it calls handle. If handle returns false the iterator stops. Even if handle returns true, values paired to non-nil error are excluded from the returned iterator.

func Rng

func Rng[Num intType](n Num) iter.Seq[Num]

Rng returns an iterator over an infinite sequence of pseudo-random numbers in the half-open interval [0,n).

func RngSourced

func RngSourced[Num intType](n Num, src rand.Source) iter.Seq[Num]

RngSourced is like Rng but accepts any arbitrary rand.Source implementations as a pseudo-random number source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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