underscore/docs/content/collections/dropwhile.md
Ruidy bcb4dd1e9d
docs: add documentation for new collection functions
Add comprehensive documentation for all new functions:
- TakeWhile: take elements while predicate is true
- DropWhile: drop elements while predicate is true
- Scan: running accumulator (prefix scan)
- First/FirstN: get first element(s) safely
- Init: all but last element
- Intersperse: insert separator between elements
- Sliding: sliding window views
- FoldRight: right-to-left fold/reduce
- Tap: side effects without mutation
- Transpose: flip matrix rows/columns
- Unzip: split tuples into separate slices
- ParallelReduce: parallel reduction (experimental)
- Replicate: create n copies of a value

Each doc includes:
- Clear description
- Code examples with output
- Common use cases
- Edge case handling

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 08:48:38 +01:00

691 B

title date
DropWhile 2025-01-16T00:00:00-00:00

DropWhile drops elements from the beginning of the slice while the predicate returns true. It returns the remaining elements starting from the first element where the predicate returns false.

package main

import (
 "fmt"
 u "github.com/rjNemo/underscore"
)

func main() {
 nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
 lessThan5 := func(n int) bool { return n < 5 }
 fmt.Println(u.DropWhile(nums, lessThan5)) // [5, 6, 7, 8, 9]

 words := []string{"apple", "banana", "cherry", "date"}
 shortWords := func(s string) bool { return len(s) < 6 }
 fmt.Println(u.DropWhile(words, shortWords)) // ["banana", "cherry", "date"]
}