Categorygithub.com/demdxx/xtypes
repositorypackage
0.2.0
Repository: https://github.com/demdxx/xtypes.git
Documentation: pkg.go.dev

# README

XTypes

License GoDoc Testing Status Go Report Card Coverage Status

Package represents basic go types and collections with extended functionalty.

Collections

Slice

Slice[int]([]int{1, 2, 3}).
  Filter(func(val int) bool { return val > 1 }).
  // [2, 3]
  Apply(func(val int) int { return val * val }).
  // [4, 9]
  Sort(func(a, b int) bool { return a > b }).
  // [9, 4]
  ReduceIntoOne(func(val int, ret *int) { *ret += val })
  // 13

SliceReduce([]int{1, 2, 3}, func(val int, ret *float64) { *ret += 1/float64(val) })
// 1.83333...

LazySlice

NewLazySlice([]int{1, 2, 3}).
  Filter(func(val int) bool { return val > 1 }).
  // [2, 3]
  Apply(func(val int) int { return val * val }).
  // [4, 9]
  Commit()