lxCollection

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter, returns a new slice containing all strings in the slice that satisfy the predicate f. // Example:

fmt.Println(Filter(strs, func(v string) bool {
    return strings.Contains(v, "e")
}))

func FindAll

func FindAll(vs []string, f func(string) bool) bool

FindAll, returns true if all of the strings in the slice satisfy the predicate f. Example:

fmt.Println(FindAll(strs, func(v string) bool {
    return strings.HasPrefix(v, "p")
}))

func FindAny

func FindAny(vs []string, f func(string) bool) bool

FindAny, returns true if one of the strings in the slice satisfies the predicate f. Example:

fmt.Println(FindAny(strs, func(v string) bool {
    return strings.HasPrefix(v, "p")
}))

func FirstIndex

func FirstIndex(vs []string, t string) int

FirstIndex, returns the first index of the target string, or -1 if no match is found. Example: fmt.Println(FirstIndex(strs, "pear"))

func Include

func Include(vs []string, t string) bool

Include, returns true if the target string t is in the slice. Example: fmt.Println(Include(strs, "grape"))

func Map

func Map(vs []string, f func(string) string) []string

Map, returns a new slice, containing the results of applying the function f to each string in the original slice. Example: fmt.Println(Map(strs, strings.ToUpper))

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL