This Go package is crafted to help developers embrace functional programming paradigms in Go. With a suite of utility functions, this package encourages immutable coding practices, helping you move away from traditional mutable loops like for loops. Together
GNU Lesser General Public License v3.0
0
stars
2
forks
source link
need Pipeline function, Similar to Chain, but it allows you to explicitly chain multiple transformations into a single operation #38
func Pipeline[T any](initial T, funcs ...func(T) T) T
Description: Similar to Chain, but it allows you to explicitly chain multiple transformations into a single operation. It can be especially useful when you want to process data through several independent steps.
Why: Provides a clean and declarative way to process data in multiple steps.
result := Pipeline(5, func(x int) int { return x * 2 }, func(x int) int { return x + 3 })
// result = 13
func Pipeline[T any](initial T, funcs ...func(T) T) T
Description: Similar to Chain, but it allows you to explicitly chain multiple transformations into a single operation. It can be especially useful when you want to process data through several independent steps.
Why: Provides a clean and declarative way to process data in multiple steps.
result := Pipeline(5, func(x int) int { return x * 2 }, func(x int) int { return x + 3 }) // result = 13