package core

// Pipeline composes a sequence of functions T -> T into a single function.
// The functions are applied left to right: Pipeline(f, g, h)(x) == h(g(f(x))).
// Returns the identity function if no functions are provided.
func Pipeline[T any](fns ...func(T) T) func(T) T {
	return func(val T) T {
		for _, fn := range fns {
			val = fn(val)
		}
		return val
	}
}
