Documentation
¶
Overview ¶
Package lof provides utility functions for functional programming.
Index ¶
- func Asc[T cmp.Ordered](a, b T) int
- func Desc[T cmp.Ordered](a, b T) int
- func Identity[T any](t T) T
- func IfNonEmpty(s string) (string, bool)
- func Inc(n int) int
- func IntAsc(a, b int) int
- func IntDesc(a, b int) int
- func IntIdentity(n int) int
- func IsNonBlank(s string) bool
- func IsNonEmpty(s string) bool
- func Len[T any](ts []T) int
- func Println(s string)
- func StringAsc(a, b string) int
- func StringDesc(a, b string) int
- func StringIdentity(s string) string
- func StringLen(s string) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Identity ¶ added in v0.41.0
func Identity[T any](t T) T
Identity returns its argument unchanged. Use as a function value via type instantiation: lof.Identity[string]
func IfNonEmpty ¶ added in v0.30.0
IfNonEmpty returns s and whether s is non-empty. Converts "empty string = absent" returns to Go's comma-ok idiom.
result := cmp.Diff(want, got)
if diff, ok := lof.IfNonEmpty(result); ok {
t.Errorf("mismatch:\n%s", diff)
}
func Inc ¶ added in v0.41.0
Inc returns n + 1. Successor function for use with stream.Generate and similar.
func IntIdentity ¶ added in v0.41.0
IntIdentity returns its int argument unchanged.
func IsNonBlank ¶ added in v0.30.0
IsNonBlank returns true if s contains non-whitespace characters.
func IsNonEmpty ¶ added in v0.30.0
IsNonEmpty returns true if s is non-empty.
func StringDesc ¶ added in v0.41.0
StringDesc is a descending comparator for strings.
func StringIdentity ¶ added in v0.41.0
StringIdentity returns its string argument unchanged.
Types ¶
This section is empty.