ExampleSet_ApplyFunc demonstrates transforming set elements
()
| 103 | |
| 104 | // ExampleSet_ApplyFunc demonstrates transforming set elements |
| 105 | func 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 |
| 122 | func ExampleSet_FuncMatch() { |
nothing calls this directly
no test coverage detected