mirror of
https://github.com/rjNemo/underscore
synced 2026-06-08 11:36:42 +00:00
- Add Tap: for side effects/debugging in pipelines - Add Transpose: flip matrix rows and columns - Add Unzip: split tuple slice into two slices - Add ParallelReduce: parallel reduction (experimental) - Add Replicate: create n copies of a value Comprehensive tests included for all functions. Resolves Issues 21, 22, 23, 24, 25 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
12 lines
378 B
Go
12 lines
378 B
Go
package underscore
|
|
|
|
// Tap applies a function to each element for side effects (like debugging/logging)
|
|
// and returns the original slice unchanged. Useful for debugging pipelines.
|
|
//
|
|
// Example: Tap([]int{1,2,3}, func(n int) { fmt.Println(n) }) → [1,2,3] (and prints each)
|
|
func Tap[T any](values []T, fn func(T)) []T {
|
|
for _, v := range values {
|
|
fn(v)
|
|
}
|
|
return values
|
|
}
|