1
0
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:
Carsten Leue
2023-09-13 15:04:50 +02:00
committed by GitHub
3 changed files with 4 additions and 0 deletions

View File

@@ -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 {
return t2
}

View File

@@ -62,6 +62,7 @@ func First[T1, T2 any](t1 T1, _ T2) T1 {
}
// Second returns the second out of two input values
// Identical to [SK]
func Second[T1, T2 any](_ T1, t2 T2) T2 {
return t2
}

View File

@@ -21,10 +21,12 @@ func Of[T1 any](t T1) Tuple1[T1] {
return MakeTuple1(t)
}
// First returns the first element of a [Tuple2]
func First[T1, T2 any](t Tuple2[T1, T2]) T1 {
return t.F1
}
// Second returns the second element of a [Tuple2]
func Second[T1, T2 any](t Tuple2[T1, T2]) T2 {
return t.F2
}