MCPcopy Create free account
hub / github.com/github/gh-aw / Filter

Function Filter

pkg/sliceutil/sliceutil.go:16–24  ·  view source on GitHub ↗

Filter returns a new slice containing only elements that match the predicate. This is a pure function that does not modify the input slice.

(slice []T, predicate func(T) bool)

Source from the content-addressed store, hash-verified

14// Filter returns a new slice containing only elements that match the predicate.
15// This is a pure function that does not modify the input slice.
16func Filter[T any](slice []T, predicate func(T) bool) []T {
17 result := make([]T, 0, len(slice))
18 for _, item := range slice {
19 if predicate(item) {
20 result = append(result, item)
21 }
22 }
23 return result
24}
25
26// Map transforms each element in a slice using the provided function.
27// This is a pure function that does not modify the input slice.

Callers 10

expandLocalWildcardFunction · 0.92
getActionDirectoriesFunction · 0.92
parseSecretNamesFunction · 0.92
analyzeFirewallLogsFunction · 0.92
CompleteEngineNamesFunction · 0.92
buildScheduleOptionsFunction · 0.92
filterWorkflowFilesFunction · 0.92
TestFilterFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestFilterFunction · 0.68