Skip to content

Commit

Permalink
Merge pull request #45 from IBM/cleue-prefer-second-over-SK
Browse files Browse the repository at this point in the history
doc: ad doc to SK function
  • Loading branch information
CarstenLeue authored Sep 13, 2023
2 parents da1449e + 9a9d13b commit 34844bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions function/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions tuple/tuple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 34844bc

Please sign in to comment.