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

Function ExampleSet_ApplyFunc

pkg/set/example_test.go:105–119  ·  view source on GitHub ↗

ExampleSet_ApplyFunc demonstrates transforming set elements

()

Source from the content-addressed store, hash-verified

103
104// ExampleSet_ApplyFunc demonstrates transforming set elements
105func ExampleSet_ApplyFunc() {
106 numbers := set.Create(1, 2, 3, 4, 5)
107
108 // Square each number
109 squared := numbers.ApplyFunc(func(n int) int {
110 return n * n
111 })
112
113 fmt.Println("Original:", set.ToSliceOrdered(numbers))
114 fmt.Println("Squared:", set.ToSliceOrdered(squared))
115
116 // Output:
117 // Original: [1 2 3 4 5]
118 // Squared: [1 4 9 16 25]
119}
120
121// ExampleSet_FuncMatch demonstrates filtering set elements
122func ExampleSet_FuncMatch() {

Callers

nothing calls this directly

Calls 3

CreateFunction · 0.92
ToSliceOrderedFunction · 0.92
ApplyFuncMethod · 0.45

Tested by

no test coverage detected