Skip to content

Conversation

@rjNemo
Copy link
Owner

@rjNemo rjNemo commented Nov 14, 2025

Summary

  • Add Scan: returns all intermediate accumulator values during reduction
  • Also known as prefix scan or cumulative fold

Implementation

  • scan.go: Scan implementation with proper memory pre-allocation
  • Comprehensive tests including edge cases, different operations, and type conversions
  • Benchmark included

Testing

go test -v -run TestScan
go test -bench=BenchmarkScan -benchmem

All tests pass.

Examples

// Running sum
Scan([]int{1,2,3,4}, 0, func(acc, n int) int { return acc + n })
// → [1, 3, 6, 10]

// Running max
Scan([]int{3,1,4,1,5}, 0, func(acc, n int) int {
    if n > acc { return n }
    return acc
})
// → [3, 3, 4, 4, 5]

// String concatenation
Scan([]string{"a", "b", "c"}, "", func(acc, s string) string { return acc + s })
// → ["a", "ab", "abc"]

Related

Resolves Issue 15 from ACTION_PLAN.md

🤖 Generated with Claude Code

- Add Scan: returns all intermediate accumulator values
- Also known as prefix scan or cumulative fold
- Comprehensive tests including edge cases and different types
- Benchmark included

Example: Scan([]int{1,2,3,4}, 0, +) → [1, 3, 6, 10]

Resolves Issue 15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (d622c8c) to head (5c8e892).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #43      +/-   ##
==========================================
+ Coverage   98.63%   98.66%   +0.02%     
==========================================
  Files          39       40       +1     
  Lines         367      375       +8     
==========================================
+ Hits          362      370       +8     
  Misses          4        4              
  Partials        1        1              
Flag Coverage Δ
unittests 98.66% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rjNemo rjNemo merged commit 0bf04c2 into main Nov 16, 2025
4 checks passed
@rjNemo rjNemo deleted the feat/issue-15-scan branch November 16, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants