mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 02:26:42 +00:00
Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| a29f64b700 |
7 changed files with 7 additions and 1207 deletions
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(TestDropWhile\"\ngo test -bench=\"BenchmarkTakeWhile)",
|
||||
"Bash(gh pr create:*)",
|
||||
"Bash(TestTranspose)",
|
||||
"Bash(TestUnzip)",
|
||||
"Bash(TestParallelReduce)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -63,3 +63,4 @@ docs/public
|
|||
.claude
|
||||
AGENTS.md
|
||||
bench*txt
|
||||
ACTION_PLAN.md
|
||||
|
|
|
|||
1189
ACTION_PLAN.md
1189
ACTION_PLAN.md
File diff suppressed because it is too large
Load diff
|
|
@ -80,7 +80,7 @@ func BenchmarkFirst(b *testing.B) {
|
|||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
u.First(nums)
|
||||
_, _ = u.First(nums)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package underscore
|
|||
// Also known as foldr in Haskell.
|
||||
//
|
||||
// Example: FoldRight([]int{1,2,3}, 0, func(n, acc int) int { return n - acc })
|
||||
//
|
||||
// → 1 - (2 - (3 - 0)) = 1 - (2 - 3) = 1 - (-1) = 2
|
||||
func FoldRight[T, P any](values []T, acc P, fn func(T, P) P) P {
|
||||
for i := len(values) - 1; i >= 0; i-- {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func BenchmarkParallelMap(b *testing.B) {
|
|||
b.Run(fmt.Sprintf("workers=%d", workers), func(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
u.ParallelMap(ctx, data, workers, func(_ context.Context, n int) (int, error) {
|
||||
_, _ = u.ParallelMap(ctx, data, workers, func(_ context.Context, n int) (int, error) {
|
||||
return n * 2, nil
|
||||
})
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ func BenchmarkMapVsParallelMap(b *testing.B) {
|
|||
|
||||
b.Run("ParallelMap", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
u.ParallelMap(ctx, data, 0, func(_ context.Context, n int) (int, error) {
|
||||
_, _ = u.ParallelMap(ctx, data, 0, func(_ context.Context, n int) (int, error) {
|
||||
return n * 2, nil
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ func BenchmarkParallelReduce(b *testing.B) {
|
|||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
u.ParallelReduce(ctx, nums, 4, func(ctx context.Context, n int, acc int) (int, error) {
|
||||
_, _ = u.ParallelReduce(ctx, nums, 4, func(ctx context.Context, n int, acc int) (int, error) {
|
||||
return n + acc, nil
|
||||
}, 0)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue