This library is inspired by functional programming - Clojure
fix issues with higher versioning number
add go mod file with new version series ver1.0.0 to fix go mod issue with some internal file use with higher version.
Method chain functionality for Basic type as well as struct - Map, Filter, Sort, Distinct, Reverse, DropWhile, TakeWhile, Remove
Example:
// Use MakeIntSlicePtr for pointer version
r := fp.MakeIntSlice([]int{3, 2, 1}...).
Filter(odd).
Map(square).
Sort()
fmt.Println(r) // [1 9]
func odd (num int) bool {
return num % 2 != 0
}
func square(num int) int {
return num * num
}
Eg: PMapInt(squareInt, []int{v1, v2, v3}, Optional{FixedPool: 2, RandomOrder: true})
The default behavior of PMap: a. number of Goroutines == length of the list. b. Order is guaranteed
New functions for struct - (Distinct, Intersection, Union, Difference, Superset, Subset, Set) compares each member of a struct with another struct in the list.
New functions to compare slice and map. Equal<Type>sP : eg EqualIntsP, EqualFloats64P EqualMap<Type1><Type2>: eg. EqualMapIntP , EqualMapInt64Float64P
New function to check if the slice is distinct Distinct<Type>P: eg. DistinctIntP
Auto-generate code for struct has options to include the only list - //go:generate gofp -destination fp.go -pkg employee -type "Employee" -only "Distinct, DistinctPtr, DistinctP"
A full list of value for option only
is provided in README
Added function - Dedupe<Type> Auto-generated code for sorting for struct takes pointer types.
Auto-generated code for struct has set and sort related functions as default. Options -set or -sort will override the default behavior of auto-generation of functions related to set & sort.
Added new predicate functions: a. Zero<Type>P b. Neg<Type>P c. Pos<Type>P d. Even<Type>P e. Odd<Type>P
Auto-generated code for struct has set and sort related functions as default. Options -set or -sort will override the default behavior of auto-generation of functions related to set & sort.
Added new predicate functions: a. Zero<Type>P b. Neg<Type>P c. Pos<Type>P d. Even<Type>P e. Odd<Type>P