mirror of
https://github.com/IBM/fp-go.git
synced 2025-06-17 00:07:49 +02:00
11 lines
195 B
Go
11 lines
195 B
Go
![]() |
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)
|
||
|
}
|
||
|
}
|