MCPcopy
hub / github.com/minio/minio-go / ExampleSet_FuncMatch

Function ExampleSet_FuncMatch

pkg/set/example_test.go:122–141  ·  view source on GitHub ↗

ExampleSet_FuncMatch demonstrates filtering set elements

()

Source from the content-addressed store, hash-verified

120
121// ExampleSet_FuncMatch demonstrates filtering set elements
122func ExampleSet_FuncMatch() {
123 numbers := set.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
124
125 // Find all even numbers
126 evens := numbers.FuncMatch(func(n, _ int) bool {
127 return n%2 == 0
128 }, 0)
129
130 // Find all numbers greater than 5
131 greaterThanFive := numbers.FuncMatch(func(n, threshold int) bool {
132 return n > threshold
133 }, 5)
134
135 fmt.Println("Even numbers:", set.ToSliceOrdered(evens))
136 fmt.Println("Greater than 5:", set.ToSliceOrdered(greaterThanFive))
137
138 // Output:
139 // Even numbers: [2 4 6 8 10]
140 // Greater than 5: [6 7 8 9 10]
141}
142
143// ExampleCopy demonstrates copying a set
144func ExampleCopy() {

Callers

nothing calls this directly

Calls 3

CreateFunction · 0.92
ToSliceOrderedFunction · 0.92
FuncMatchMethod · 0.45

Tested by

no test coverage detected