go-funk: github.com/thoas/go-funk Index | Examples | Files

package funk

import "github.com/thoas/go-funk"

Index

Examples

Package Files

builder.go chain_builder.go compact.go fill.go helpers.go intersection.go lazy_builder.go map.go max.go min.go operation.go presence.go reduce.go retrieve.go scan.go transform.go typesafe.go utils.go zip.go

func All Uses

func All(objs ...interface{}) bool

All returns true if all elements of the iterable are not empty (or if the iterable is empty)

func Any Uses

func Any(objs ...interface{}) bool

Any returns true if any element of the iterable is not empty. If the iterable is empty, return False.

func Chunk Uses

func Chunk(arr interface{}, size int) interface{}

Chunk creates an array of elements split into groups with the length of size. If array can't be split evenly, the final chunk will be the remaining element.

func Compact Uses

func Compact(value interface{}) interface{}

Compact creates a slice with all empty/zero values removed.

func Contains Uses

func Contains(in interface{}, elem interface{}) bool

Contains returns true if an element is present in a iteratee.

func ContainsFloat32 Uses

func ContainsFloat32(s []float32, v float32) bool

ContainsFloat32 returns true if a float32 is present in a iteratee.

func ContainsFloat64 Uses

func ContainsFloat64(s []float64, v float64) bool

ContainsFloat64 returns true if a float64 is present in a iteratee.

func ContainsInt Uses

func ContainsInt(s []int, v int) bool

ContainsInt returns true if an int is present in a iteratee.

func ContainsInt32 Uses

func ContainsInt32(s []int32, v int32) bool

ContainsInt32 returns true if an int32 is present in a iteratee.

func ContainsInt64 Uses

func ContainsInt64(s []int64, v int64) bool

ContainsInt64 returns true if an int64 is present in a iteratee.

func ContainsString Uses

func ContainsString(s []string, v string) bool

ContainsString returns true if a string is present in a iteratee.

func ConvertSlice Uses

func ConvertSlice(in interface{}, out interface{})

ConvertSlice converts a slice type to another, a perfect example would be to convert a slice of struct to a slice of interface.

func Drop Uses

func Drop(in interface{}, n int) interface{}

Drop creates an array/slice with `n` elements dropped from the beginning.

func DropFloat32 Uses

func DropFloat32(s []float32, n int) []float32

DropFloat32 creates a slice with `n` float32s dropped from the beginning.

func DropFloat64 Uses

func DropFloat64(s []float64, n int) []float64

DropFloat64 creates a slice with `n` float64s dropped from the beginning.

func DropInt Uses

func DropInt(s []int, n int) []int

DropInt creates a slice with `n` ints dropped from the beginning.

func DropInt32 Uses

func DropInt32(s []int32, n int) []int32

DropInt32 creates a slice with `n` int32s dropped from the beginning.

func DropInt64 Uses

func DropInt64(s []int64, n int) []int64

DropInt64 creates a slice with `n` int64s dropped from the beginning.

func DropString Uses

func DropString(s []string, n int) []string

DropString creates a slice with `n` strings dropped from the beginning.

func Equal Uses

func Equal(expected interface{}, actual interface{}) bool

Equal returns if the two objects are equal

func Every Uses

func Every(in interface{}, elements ...interface{}) bool

Every returns true if every element is present in a iteratee.

func Fill Uses

func Fill(in interface{}, fillValue interface{}) (interface{}, error)

Fill fills elements of array with value

func Filter Uses

func Filter(arr interface{}, predicate interface{}) interface{}

Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for.

func FilterFloat32 Uses

func FilterFloat32(s []float32, cb func(s float32) bool) []float32

FilterFloat32 iterates over a collection of float32, returning an array of all float32 elements predicate returns truthy for.

func FilterFloat64 Uses

func FilterFloat64(s []float64, cb func(s float64) bool) []float64

FilterFloat64 iterates over a collection of float64, returning an array of all float64 elements predicate returns truthy for.

func FilterInt Uses

func FilterInt(s []int, cb func(s int) bool) []int

FilterInt iterates over a collection of int, returning an array of all int elements predicate returns truthy for.

func FilterInt32 Uses

func FilterInt32(s []int32, cb func(s int32) bool) []int32

FilterInt32 iterates over a collection of int32, returning an array of all int32 elements predicate returns truthy for.

func FilterInt64 Uses

func FilterInt64(s []int64, cb func(s int64) bool) []int64

FilterInt64 iterates over a collection of int64, returning an array of all int64 elements predicate returns truthy for.

func FilterString Uses

func FilterString(s []string, cb func(s string) bool) []string

FilterString iterates over a collection of string, returning an array of all string elements predicate returns truthy for.

func Find Uses

func Find(arr interface{}, predicate interface{}) interface{}

Find iterates over elements of collection, returning the first element predicate returns truthy for.

func FindFloat32 Uses

func FindFloat32(s []float32, cb func(s float32) bool) (float32, bool)

FindFloat32 iterates over a collection of float32, returning the first float32 element predicate returns truthy for.

func FindFloat64 Uses

func FindFloat64(s []float64, cb func(s float64) bool) (float64, bool)

FindFloat64 iterates over a collection of float64, returning an array of all float64 elements predicate returns truthy for.

func FindInt Uses

func FindInt(s []int, cb func(s int) bool) (int, bool)

FindInt iterates over a collection of int, returning the first int element predicate returns truthy for.

func FindInt32 Uses

func FindInt32(s []int32, cb func(s int32) bool) (int32, bool)

FindInt32 iterates over a collection of int32, returning the first int32 element predicate returns truthy for.

func FindInt64 Uses

func FindInt64(s []int64, cb func(s int64) bool) (int64, bool)

FindInt64 iterates over a collection of int64, returning the first int64 element predicate returns truthy for.

func FindKey Uses

func FindKey(arr interface{}, predicate interface{}) (matchKey, matchEle interface{})

Find iterates over elements of collection, returning the first element of an array and random of a map which predicate returns truthy for.

func FindString Uses

func FindString(s []string, cb func(s string) bool) (string, bool)

FindString iterates over a collection of string, returning the first string element predicate returns truthy for.

func FlattenDeep Uses

func FlattenDeep(out interface{}) interface{}

FlattenDeep recursively flattens array.

func ForEach Uses

func ForEach(arr interface{}, predicate interface{})

ForEach iterates over elements of collection and invokes iteratee for each element.

func ForEachRight Uses

func ForEachRight(arr interface{}, predicate interface{})

ForEachRight iterates over elements of collection from the right and invokes iteratee for each element.

func Get Uses

func Get(out interface{}, path string) interface{}

Get retrieves the value at path of struct(s).

func Head(arr interface{}) interface{}

Head gets the first element of array.

func InFloat32s Uses

func InFloat32s(s []float32, v float32) bool

InFloat32s is an alias of ContainsFloat32, returns true if a float32 is present in a iteratee.

func InFloat64s Uses

func InFloat64s(s []float64, v float64) bool

InFloat64s is an alias of ContainsFloat64, returns true if a float64 is present in a iteratee.

func InInt32s Uses

func InInt32s(s []int32, v int32) bool

InInt32s is an alias of ContainsInt32, returns true if an int32 is present in a iteratee.

func InInt64s Uses

func InInt64s(s []int64, v int64) bool

InInt64s is an alias of ContainsInt64, returns true if an int64 is present in a iteratee.

func InInts Uses

func InInts(s []int, v int) bool

InInts is an alias of ContainsInt, returns true if an int is present in a iteratee.

func InStrings Uses

func InStrings(s []string, v string) bool

InStrings is an alias of ContainsString, returns true if a string is present in a iteratee.

func IndexOf Uses

func IndexOf(in interface{}, elem interface{}) int

IndexOf gets the index at which the first occurrence of value is found in array or return -1 if the value cannot be found

func IndexOfFloat64 Uses

func IndexOfFloat64(a []float64, x float64) int

IndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 if the value cannot be found

func IndexOfInt Uses

func IndexOfInt(a []int, x int) int

IndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 if the value cannot be found

func IndexOfInt32 Uses

func IndexOfInt32(a []int32, x int32) int

IndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 if the value cannot be found

func IndexOfInt64 Uses

func IndexOfInt64(a []int64, x int64) int

IndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 if the value cannot be found

func IndexOfString Uses

func IndexOfString(a []string, x string) int

IndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 if the value cannot be found

func Initial Uses

func Initial(arr interface{}) interface{}

Initial gets all but the last element of array.

func Intersect Uses

func Intersect(x interface{}, y interface{}) interface{}

Intersect returns the intersection between two collections.

func IntersectString Uses

func IntersectString(x []string, y []string) []string

IntersectString returns the intersection between two collections of string.

func IsCollection Uses

func IsCollection(in interface{}) bool

IsCollection returns if the argument is a collection.

func IsEmpty Uses

func IsEmpty(obj interface{}) bool

IsEmpty returns if the object is considered as empty or not.

func IsEqual Uses

func IsEqual(expected interface{}, actual interface{}) bool

IsEqual returns if the two objects are equal

func IsFunction Uses

func IsFunction(in interface{}, num ...int) bool

IsFunction returns if the argument is a function.

func IsIteratee Uses

func IsIteratee(in interface{}) bool

IsIteratee returns if the argument is an iteratee.

func IsType Uses

func IsType(expected interface{}, actual interface{}) bool

IsType returns if the two objects are in the same type

func IsZero Uses

func IsZero(obj interface{}) bool

IsZero returns if the object is considered as zero value

func Keys Uses

func Keys(out interface{}) interface{}

Keys creates an array of the own enumerable map keys or struct field names.

func Last Uses

func Last(arr interface{}) interface{}

Last gets the last element of array.

func LastIndexOf Uses

func LastIndexOf(in interface{}, elem interface{}) int

LastIndexOf gets the index at which the last occurrence of value is found in array or return -1 if the value cannot be found

func LastIndexOfFloat32 Uses

func LastIndexOfFloat32(a []float32, x float32) int

LastIndexOfFloat32 gets the index at which the first occurrence of an float32 value is found in array or return -1 if the value cannot be found

func LastIndexOfFloat64 Uses

func LastIndexOfFloat64(a []float64, x float64) int

LastIndexOfFloat64 gets the index at which the first occurrence of an float64 value is found in array or return -1 if the value cannot be found

func LastIndexOfInt Uses

func LastIndexOfInt(a []int, x int) int

LastIndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1 if the value cannot be found

func LastIndexOfInt32 Uses

func LastIndexOfInt32(a []int32, x int32) int

LastIndexOfInt32 gets the index at which the first occurrence of an int32 value is found in array or return -1 if the value cannot be found

func LastIndexOfInt64 Uses

func LastIndexOfInt64(a []int64, x int64) int

LastIndexOfInt64 gets the index at which the first occurrence of an int64 value is found in array or return -1 if the value cannot be found

func LastIndexOfString Uses

func LastIndexOfString(a []string, x string) int

LastIndexOfString gets the index at which the first occurrence of a string value is found in array or return -1 if the value cannot be found

func Map Uses

func Map(arr interface{}, mapFunc interface{}) interface{}

Map manipulates an iteratee and transforms it to another type.

func MaxFloat32 Uses

func MaxFloat32(i []float32) interface{}

MaxFloat32 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []float32 It returns float32 or nil It returns nil for the following cases:

- input is of length 0

func MaxFloat64 Uses

func MaxFloat64(i []float64) interface{}

MaxFloat64 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []float64 It returns float64 or nil It returns nil for the following cases:

- input is of length 0

func MaxInt Uses

func MaxInt(i []int) interface{}

MaxInt validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []int It returns int or nil It returns nil for the following cases:

- input is of length 0

func MaxInt16 Uses

func MaxInt16(i []int16) interface{}

MaxInt16 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []int16 It returns int16 or nil It returns nil for the following cases:

- input is of length 0

func MaxInt32 Uses

func MaxInt32(i []int32) interface{}

MaxInt32 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []int32 It returns int32 or nil It returns nil for the following cases:

- input is of length 0

func MaxInt64 Uses

func MaxInt64(i []int64) interface{}

MaxInt64 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []int64 It returns int64 or nil It returns nil for the following cases:

- input is of length 0

func MaxInt8 Uses

func MaxInt8(i []int8) interface{}

MaxInt8 validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []int8 It returns int8 or nil It returns nil for the following cases:

- input is of length 0

func MaxString Uses

func MaxString(i []string) interface{}

MaxString validates the input, compares the elements and returns the maximum element in an array/slice. It accepts []string It returns string or nil It returns nil for the following cases:

- input is of length 0

func MinFloat32 Uses

func MinFloat32(i []float32) interface{}

MinFloat32 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []float32 It returns float32 or nil It returns nil for the following cases:

- input is of length 0

func MinFloat64 Uses

func MinFloat64(i []float64) interface{}

MinFloat64 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []float64 It returns float64 or nil It returns nil for the following cases:

- input is of length 0

func MinInt Uses

func MinInt(i []int) interface{}

MinInt validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []int It returns int or nil It returns nil for the following cases:

- input is of length 0

func MinInt16 Uses

func MinInt16(i []int16) interface{}

MinInt16 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []int16 It returns int16 or nil It returns nil for the following cases:

- input is of length 0

func MinInt32 Uses

func MinInt32(i []int32) interface{}

MinInt32 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []int32 It returns int32 or nil It returns nil for the following cases:

- input is of length 0

func MinInt64 Uses

func MinInt64(i []int64) interface{}

MinInt64 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []int64 It returns int64 or nil It returns nil for the following cases:

- input is of length 0

func MinInt8 Uses

func MinInt8(i []int8) interface{}

MinInt8 validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []int8 It returns int8 or nil It returns nil for the following cases:

- input is of length 0

func MinString Uses

func MinString(i []string) interface{}

MinString validates the input, compares the elements and returns the minimum element in an array/slice. It accepts []string It returns string or nil It returns nil for the following cases:

- input is of length 0

func NotEmpty Uses

func NotEmpty(obj interface{}) bool

NotEmpty returns if the object is considered as non-empty or not.

func NotEqual Uses

func NotEqual(expected interface{}, actual interface{}) bool

NotEqual returns if the two objects are not equal

func Product Uses

func Product(arr interface{}) float64

Product computes the product of the values in array.

func PtrOf Uses

func PtrOf(itf interface{}) interface{}

PtrOf makes a copy of the given interface and returns a pointer.

func RandomInt Uses

func RandomInt(min, max int) int

RandomInt generates a random int, based on a min and max values

func RandomString Uses

func RandomString(n int, allowedChars ...[]rune) string

RandomString returns a random string with a fixed length

func Reduce Uses

func Reduce(arr, reduceFunc, acc interface{}) float64

Reduce takes a collection and reduces it to a single value using a reduction function (or a valid symbol) and an accumulator value.

func Reverse Uses

func Reverse(in interface{}) interface{}

Reverse transforms an array the first element will become the last, the second element will become the second to last, etc.

func ReverseFloat32 Uses

func ReverseFloat32(s []float32) []float32

ReverseFloat32 reverses an array of float32

func ReverseFloat64 Uses

func ReverseFloat64(s []float64) []float64

ReverseFloat64 reverses an array of float64

func ReverseInt Uses

func ReverseInt(s []int) []int

ReverseInt reverses an array of int

func ReverseInt32 Uses

func ReverseInt32(s []int32) []int32

ReverseInt32 reverses an array of int32

func ReverseInt64 Uses

func ReverseInt64(s []int64) []int64

ReverseInt64 reverses an array of int64

func ReverseString Uses

func ReverseString(s string) string

ReverseString reverses a string

func ReverseStrings Uses

func ReverseStrings(s []string) []string

ReverseStrings reverses an array of string

func Shard Uses

func Shard(str string, width int, depth int, restOnly bool) []string

Shard will shard a string name

func Shuffle Uses

func Shuffle(in interface{}) interface{}

Shuffle creates an array of shuffled values

func ShuffleFloat32 Uses

func ShuffleFloat32(a []float32) []float32

ShuffleFloat32 creates an array of float32 shuffled values using Fisher–Yates algorithm

func ShuffleFloat64 Uses

func ShuffleFloat64(a []float64) []float64

ShuffleFloat64 creates an array of float64 shuffled values using Fisher–Yates algorithm

func ShuffleInt Uses

func ShuffleInt(a []int) []int

ShuffleInt creates an array of int shuffled values using Fisher–Yates algorithm

func ShuffleInt32 Uses

func ShuffleInt32(a []int32) []int32

ShuffleInt32 creates an array of int32 shuffled values using Fisher–Yates algorithm

func ShuffleInt64 Uses

func ShuffleInt64(a []int64) []int64

ShuffleInt64 creates an array of int64 shuffled values using Fisher–Yates algorithm

func ShuffleString Uses

func ShuffleString(a []string) []string

ShuffleString creates an array of string shuffled values using Fisher–Yates algorithm

func SliceOf Uses

func SliceOf(in interface{}) interface{}

SliceOf returns a slice which contains the element.

func Some Uses

func Some(in interface{}, elements ...interface{}) bool

Some returns true if atleast one element is present in an iteratee.

Code:

a := []string{"foo", "bar", "baz"}
fmt.Println(Some(a, "foo", "qux"))

b := "Mark Shaun"
fmt.Println(Some(b, "Marc", "Sean"))

Output:

true
false

func Sum Uses

func Sum(arr interface{}) float64

Sum computes the sum of the values in array.

func SumFloat32 Uses

func SumFloat32(s []float32) (sum float32)

SumFloat32 sums a float32 iteratee and returns the sum of all elements

func SumFloat64 Uses

func SumFloat64(s []float64) (sum float64)

SumFloat64 sums a float64 iteratee and returns the sum of all elements

func SumInt Uses

func SumInt(s []int) (sum int)

SumInt sums a int iteratee and returns the sum of all elements

func SumInt32 Uses

func SumInt32(s []int32) (sum int32)

SumInt32 sums a int32 iteratee and returns the sum of all elements

func SumInt64 Uses

func SumInt64(s []int64) (sum int64)

SumInt64 sums a int64 iteratee and returns the sum of all elements

func Tail Uses

func Tail(arr interface{}) interface{}

Tail gets all but the first element of array.

func ToFloat64 Uses

func ToFloat64(x interface{}) (float64, bool)

ToFloat64 converts any numeric value to float64.

func ToMap Uses

func ToMap(in interface{}, pivot string) interface{}

ToMap transforms a slice of instances to a Map. []*Foo => Map<int, *Foo>

func Uniq Uses

func Uniq(in interface{}) interface{}

Uniq creates an array with unique values.

func UniqFloat32 Uses

func UniqFloat32(a []float32) []float32

UniqFloat32 creates an array of float32 with unique values.

func UniqFloat64 Uses

func UniqFloat64(a []float64) []float64

UniqFloat64 creates an array of float64 with unique values.

func UniqInt Uses

func UniqInt(a []int) []int

UniqInt creates an array of int with unique values.

func UniqInt32 Uses

func UniqInt32(a []int32) []int32

UniqInt32 creates an array of int32 with unique values.

func UniqInt64 Uses

func UniqInt64(a []int64) []int64

UniqInt64 creates an array of int64 with unique values.

func UniqString Uses

func UniqString(a []string) []string

UniqString creates an array of string with unique values.

func Values Uses

func Values(out interface{}) interface{}

Values creates an array of the own enumerable map values or struct field values.

func ZeroOf Uses

func ZeroOf(in interface{}) interface{}

ZeroOf returns a zero value of an element.

type Builder Uses

type Builder interface {
    Chunk(size int) Builder
    Compact() Builder
    Drop(n int) Builder
    Filter(predicate interface{}) Builder
    FlattenDeep() Builder
    Initial() Builder
    Intersect(y interface{}) Builder
    Map(mapFunc interface{}) Builder
    Reverse() Builder
    Shuffle() Builder
    Tail() Builder
    Uniq() Builder

    All() bool
    Any() bool
    Contains(elem interface{}) bool
    Every(elements ...interface{}) bool
    Find(predicate interface{}) interface{}
    ForEach(predicate interface{})
    ForEachRight(predicate interface{})
    Head() interface{}
    Keys() interface{}
    IndexOf(elem interface{}) int
    IsEmpty() bool
    Last() interface{}
    LastIndexOf(elem interface{}) int
    NotEmpty() bool
    Product() float64
    Reduce(reduceFunc, acc interface{}) float64
    Sum() float64
    Type() reflect.Type
    Value() interface{}
    Values() interface{}
}

Builder contains all tools which can be chained.

func Chain Uses

func Chain(v interface{}) Builder

Chain creates a simple new go-funk.Builder from a collection. Each method call generate a new builder containing the previous result.

Code:

v := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
chain := Chain(v)
lazy := LazyChain(v)

// Without builder
a := Filter(v, func(x int) bool { return x%2 == 0 })
b := Map(a, func(x int) int { return x * 2 })
c := Reverse(a)
fmt.Printf("funk.Contains(b, 2): %v\n", Contains(b, 2)) // false
fmt.Printf("funk.Contains(b, 4): %v\n", Contains(b, 4)) // true
fmt.Printf("funk.Sum(b): %v\n", Sum(b))                 // 40
fmt.Printf("funk.Head(b): %v\n", Head(b))               // 4
fmt.Printf("funk.Head(c): %v\n\n", Head(c))             // 8

// With simple chain builder
ca := chain.Filter(func(x int) bool { return x%2 == 0 })
cb := ca.Map(func(x int) int { return x * 2 })
cc := ca.Reverse()
fmt.Printf("chainB.Contains(2): %v\n", cb.Contains(2)) // false
fmt.Printf("chainB.Contains(4): %v\n", cb.Contains(4)) // true
fmt.Printf("chainB.Sum(): %v\n", cb.Sum())             // 40
fmt.Printf("chainB.Head(): %v\n", cb.Head())           // 4
fmt.Printf("chainC.Head(): %v\n\n", cc.Head())         // 8

// With lazy chain builder
la := lazy.Filter(func(x int) bool { return x%2 == 0 })
lb := la.Map(func(x int) int { return x * 2 })
lc := la.Reverse()
fmt.Printf("lazyChainB.Contains(2): %v\n", lb.Contains(2)) // false
fmt.Printf("lazyChainB.Contains(4): %v\n", lb.Contains(4)) // true
fmt.Printf("lazyChainB.Sum(): %v\n", lb.Sum())             // 40
fmt.Printf("lazyChainB.Head(): %v\n", lb.Head())           // 4
fmt.Printf("lazyChainC.Head(): %v\n", lc.Head())           // 8

func LazyChain Uses

func LazyChain(v interface{}) Builder

LazyChain creates a lazy go-funk.Builder from a collection. Each method call generate a new builder containing a method generating the previous value. With that, all data are only generated when we call a tailling method like All or Find.

Code:

us := updatingStruct{}
chain := Chain(us.x).
    Map(func(x int) float64 { return float64(x) * 2.5 })
lazy := LazyChain(us.x).
    Map(func(x int) float64 { return float64(x) * 2.5 })
lazyWith := LazyChainWith(us.Values).
    Map(func(x int) float64 { return float64(x) * 2.5 })

fmt.Printf("chain.Sum(): %v\n", chain.Sum())         // 0
fmt.Printf("lazy.Sum(): %v\n", lazy.Sum())           // 0
fmt.Printf("lazyWith.Sum(): %v\n\n", lazyWith.Sum()) // 0

us.x = append(us.x, 2)
fmt.Printf("chain.Sum(): %v\n", chain.Sum())         // 0
fmt.Printf("lazy.Sum(): %v\n", lazy.Sum())           // 0
fmt.Printf("lazyWith.Sum(): %v\n\n", lazyWith.Sum()) // 5

us.x = append(us.x, 10)
fmt.Printf("chain.Sum(): %v\n", chain.Sum())         // 0
fmt.Printf("lazy.Sum(): %v\n", lazy.Sum())           // 0
fmt.Printf("lazyWith.Sum(): %v\n\n", lazyWith.Sum()) // 30

func LazyChainWith Uses

func LazyChainWith(generator func() interface{}) Builder

LazyChainWith creates a lzy go-funk.Builder from a generator. Like LazyChain, each method call generate a new builder containing a method generating the previous value. But, instead of using a collection, it takes a generator which can generate values. With LazyChainWith, to can create a generic pipeline of collection transformation and, throw the generator, sending different collection.

type Tuple Uses

type Tuple struct {
    Element1 interface{}
    Element2 interface{}
}

Tuple is the return type of Zip

func Zip Uses

func Zip(slice1 interface{}, slice2 interface{}) []Tuple

Zip returns a list of tuples, where the i-th tuple contains the i-th element from each of the input iterables. The returned list is truncated in length to the length of the shortest input iterable.

Package funk imports 6 packages (graph) and is imported by 59 packages. Updated 2019-11-25. Refresh now. Tools for package owners.