1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-17 00:07:49 +02:00
Files
fp-go/function/ternary.go

11 lines
195 B
Go
Raw Normal View History

package function
func Ternary[A, B any](pred func(A) bool, onTrue func(A) B, onFalse func(A) B) func(A) B {
return func(a A) B {
if pred(a) {
return onTrue(a)
}
return onFalse(a)
}
}