Skip to content

Conversation

@rjNemo
Copy link
Owner

@rjNemo rjNemo commented Nov 14, 2025

Summary

  • Add TakeWhile: returns elements from the beginning while predicate is true
  • Add DropWhile: drops elements from the beginning while predicate is true

Implementation

  • takewhile.go: TakeWhile implementation with proper memory allocation
  • dropwhile.go: DropWhile implementation with proper memory allocation
  • Comprehensive tests for both functions including edge cases (empty, none match, all match, single element)
  • Benchmarks included for performance validation

Testing

go test -v -run "TestTakeWhile|TestDropWhile"
go test -bench="BenchmarkTakeWhile|BenchmarkDropWhile" -benchmem

All tests pass.

Examples

nums := []int{1, 2, 3, 4, 5, 6}
TakeWhile(nums, func(n int) bool { return n < 4 }) // [1, 2, 3]
DropWhile(nums, func(n int) bool { return n < 4 }) // [4, 5, 6]

Related

Resolves Issue 14 from ACTION_PLAN.md

🤖 Generated with Claude Code

- Add TakeWhile: returns elements while predicate is true
- Add DropWhile: drops elements while predicate is true
- Comprehensive tests including edge cases
- Benchmarks included

Resolves Issue 14

🤖 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.69%. Comparing base (d622c8c) to head (482b899).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
+ Coverage   98.63%   98.69%   +0.05%     
==========================================
  Files          39       41       +2     
  Lines         367      383      +16     
==========================================
+ Hits          362      378      +16     
  Misses          4        4              
  Partials        1        1              
Flag Coverage Δ
unittests 98.69% <100.00%> (+0.05%) ⬆️

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 b35a87e into main Nov 16, 2025
4 checks passed
@rjNemo rjNemo deleted the feat/issue-14-takewhile-dropwhile 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