mirror of
https://github.com/IBM/fp-go.git
synced 2025-08-10 22:31:32 +02:00
Merge pull request #45 from IBM/cleue-prefer-second-over-SK
doc: ad doc to SK function
This commit is contained in:
@@ -26,6 +26,7 @@ func Bind2nd[T1, T2, R any](f func(T1, T2) R, t2 T2) func(T1) R {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SK function (SKI combinator calculus).
|
||||||
func SK[T1, T2 any](_ T1, t2 T2) T2 {
|
func SK[T1, T2 any](_ T1, t2 T2) T2 {
|
||||||
return t2
|
return t2
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,7 @@ func First[T1, T2 any](t1 T1, _ T2) T1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Second returns the second out of two input values
|
// Second returns the second out of two input values
|
||||||
|
// Identical to [SK]
|
||||||
func Second[T1, T2 any](_ T1, t2 T2) T2 {
|
func Second[T1, T2 any](_ T1, t2 T2) T2 {
|
||||||
return t2
|
return t2
|
||||||
}
|
}
|
||||||
|
@@ -21,10 +21,12 @@ func Of[T1 any](t T1) Tuple1[T1] {
|
|||||||
return MakeTuple1(t)
|
return MakeTuple1(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First returns the first element of a [Tuple2]
|
||||||
func First[T1, T2 any](t Tuple2[T1, T2]) T1 {
|
func First[T1, T2 any](t Tuple2[T1, T2]) T1 {
|
||||||
return t.F1
|
return t.F1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Second returns the second element of a [Tuple2]
|
||||||
func Second[T1, T2 any](t Tuple2[T1, T2]) T2 {
|
func Second[T1, T2 any](t Tuple2[T1, T2]) T2 {
|
||||||
return t.F2
|
return t.F2
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user