Last active
July 15, 2022 14:18
-
-
Save nwillc/76b4d217cee127940e1c7168b29b4f56 to your computer and use it in GitHub Desktop.
Go generics sequence signatures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All returns true if all elements in the sequence match the predicate. | |
func All[T any](sequence Sequence[T], predicate func(t T) bool) bool {...} | |
// Any returns true if any element of the sequence matches the predicate. | |
func Any[T any](sequence Sequence[T], predicate func(t T) bool) bool {...} | |
// Compare two sequences with a comparator returning less/equal/greater (-1/0/1) and return comparison of the two. | |
func Compare[T any](s1, s2 Sequence[T], comparator func(t1, t2 T) int) int {...} | |
// Find returns the first element matching the given predicate, or Result error of NoSuchElement if not found. | |
func Find[T any](sequence Sequence[T], predicate func(t T) bool) *Result[T] {...} | |
// SequenceOf creates a sequence from the provided values. | |
func SequenceOf[T any](values ...T) Sequence[T] {...} | |
// On and on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment