iter

module
v0.0.0-...-0694f89 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: MIT

README

iter

Iterators for Go using 1.18beta1 generics.

Usage

package main

import (
  "fmt"
  "strings"

  "github.com/mtoohey31/iter"
)

func main() {
  initial := iter.FromSlice([]string{"hello", "beautiful", "world"})
  result := initial.Filter(func(s string) bool {
    return len(s) < 6
  }).MapSame(func(s string) string {
    return strings.ToUpper(s)
  }).Collect()
  fmt.Println(result) // produces: [HELLO WORLD]
}

See examples/ for more demonstrations.

Notes

  • It should go without saying that since 1.18 is still beta, so is this library.
  • From what I can tell, with my limited understanding of go memory management, sliceInner struct is rather inefficient because it duplicates values and leaves past items sitting inside itself.

Similar Projects

Directories

Path Synopsis
examples
hello-world command

Jump to

Keyboard shortcuts

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