diff --git a/docs/CLAUDE.md b/docs/CLAUDE.md index 47c16af..367fe50 100644 --- a/docs/CLAUDE.md +++ b/docs/CLAUDE.md @@ -201,17 +201,94 @@ Use these established subCategories: ## Go Playground Examples -Every helper must have a working Go Playground example: -1. Create a minimal, self-contained example -2. Use realistic but simple data -3. Include the expected result as a comment -4. Test the example to ensure it works +Every helper must have a working Go Playground example linked in two places: -When creating the go playground examples, please run it to be sure it compiles and returns the expected output. If invalid, loop until it works. +1. **Source code**: `// Play: ` comment on the last line of the doc block, right before the `func` keyword +2. **Doc file**: `playUrl: ` field in the YAML frontmatter of `docs/data/-.md` -Add these examples in the source code comments, on top of helpers, with a syntax like `// Play: `. +### Creating a New Playground Example -If the documentation is created at the same time of the helper source code, then the Go playground execution might fail, since we need to merge+release the source code first to make this new helper available to Go playground compiler. In that case, skip the creation of the example and set no URL. +#### Step 1: Write the Example Code + +Write a minimal, self-contained `main.go` that demonstrates the helper. Guidelines: + +- Use realistic but simple data +- Print the result with `fmt.Println` so the output is visible +- Include edge cases when useful (e.g., empty input, error case) +- For `Err` variants, show both a success and an error case +- For time-based helpers, use `time.Date()` for deterministic output +- For random helpers (`SampleBy`, `SamplesBy`), use `rand.New(rand.NewSource(42))` for reproducible output + +#### Step 2: Import Conventions + +Use the correct import path depending on the package: + +```go +// Core helpers +import "github.com/samber/lo" +// Usage: lo.Map(...) + +// Iterator helpers (it/ package, requires Go 1.23+) +import ( + "slices" + "github.com/samber/lo/it" +) +// Usage: slices.Collect(it.Map(...)) +// Convert slices to iterators: slices.Values([]int{1, 2, 3}) + +// Parallel helpers +import lop "github.com/samber/lo/parallel" +// Usage: lop.Map(...) +``` + +#### Step 3: Run and Share via Go Playground + +Use the `go-playground` MCP tool to execute the example and get a shareable URL: + +``` +mcp__go-playground__run_and_share_go_code(code: "") +``` + +This compiles the code on go.dev/play, runs it, and returns: +- The program output (to verify correctness) +- A shareable URL like `https://go.dev/play/p/XXXXXXX` + +If the output doesn't match expectations, fix the code and re-run until it produces the correct result. + +#### Step 4: Add the URL to Source Code + +Add a `// Play:` comment as the **last line** of the function's doc comment block: + +```go +// Map manipulates a slice and transforms it to a slice of another type. +// Play: https://go.dev/play/p/refNB9ZTIGo +func Map[T any, R any](collection []T, iteratee func(item T, index int) R) []R { +``` + +#### Step 5: Add the URL to Documentation + +Set the `playUrl` field in the corresponding `docs/data/*.md` file: + +```yaml +--- +name: Map +slug: map +playUrl: https://go.dev/play/p/refNB9ZTIGo +... +--- +``` + +### Troubleshooting + +**First-run timeouts**: The Go Playground may timeout on the first execution if `github.com/samber/lo` hasn't been cached yet. Simply retry — subsequent runs succeed because the module is cached. + +**New helpers not yet released**: If documentation is created at the same time as the helper source code, the Go Playground cannot compile it because the module version hasn't been published yet. In that case, skip the playground example and leave `playUrl` empty. Create the example after the next release. + +**SIMD helpers**: Helpers in `exp/simd/` require `go1.26+goexperiment.simd+amd64` build tags, which the Go Playground does not support. These helpers cannot have playground examples. + +### Bulk Verification + +To verify all playground URLs compile, you can use `mcp__go-playground__execute_go_playground_url` to re-run an existing URL and check the output. To read the source code of an existing playground, use `mcp__go-playground__read_go_playground_url`. ## Example: Complete File diff --git a/docs/data/core-camelcase.md b/docs/data/core-camelcase.md index 3860a86..a317e26 100644 --- a/docs/data/core-camelcase.md +++ b/docs/data/core-camelcase.md @@ -4,7 +4,7 @@ slug: camelcase sourceRef: string.go#L176 category: core subCategory: string -playUrl: https://go.dev/play/p/Go6aKwUiq59 +playUrl: https://go.dev/play/p/4JNDzaMwXkm variantHelpers: - core#string#camelcase similarHelpers: diff --git a/docs/data/core-clone.md b/docs/data/core-clone.md index beab844..0730c7c 100644 --- a/docs/data/core-clone.md +++ b/docs/data/core-clone.md @@ -4,7 +4,7 @@ slug: clone sourceRef: slice.go#L741 category: core subCategory: slice -playUrl: +playUrl: https://go.dev/play/p/66LJ2wAF0rN variantHelpers: - core#slice#clone similarHelpers: diff --git a/docs/data/core-concat.md b/docs/data/core-concat.md index 9b0c70d..d3f5bbb 100644 --- a/docs/data/core-concat.md +++ b/docs/data/core-concat.md @@ -4,7 +4,7 @@ slug: concat sourceRef: slice.go#L282 category: core subCategory: slice -playUrl: +playUrl: https://go.dev/play/p/Ux2UuR2xpRK variantHelpers: - core#slice#concat similarHelpers: diff --git a/docs/data/core-countby.md b/docs/data/core-countby.md index 8edc014..507d5f9 100644 --- a/docs/data/core-countby.md +++ b/docs/data/core-countby.md @@ -4,7 +4,7 @@ slug: countby sourceRef: slice.go#L849 category: core subCategory: slice -playUrl: https://go.dev/play/p/ByQbNYQQi4X +playUrl: https://go.dev/play/p/5GMQP5vNT4q variantHelpers: - core#slice#countby similarHelpers: diff --git a/docs/data/core-countbyerr.md b/docs/data/core-countbyerr.md index 9b9c185..c1e33b9 100644 --- a/docs/data/core-countbyerr.md +++ b/docs/data/core-countbyerr.md @@ -8,6 +8,7 @@ signatures: - "func CountByErr[T any](collection []T, predicate func(item T) (bool, error)) (int, error)" variantHelpers: - core#slice#countbyerr +playUrl: https://go.dev/play/p/7BnyPhpG6lW similarHelpers: - core#slice#countby - core#slice#count diff --git a/docs/data/core-cutprefix.md b/docs/data/core-cutprefix.md index 19948af..119057a 100644 --- a/docs/data/core-cutprefix.md +++ b/docs/data/core-cutprefix.md @@ -4,7 +4,7 @@ slug: cutprefix sourceRef: slice.go#L800 category: core subCategory: slice -playUrl: https://go.dev/play/p/7Plak4a1ICl +playUrl: https://go.dev/play/p/P1scQj53aFa variantHelpers: - core#slice#cutprefix similarHelpers: diff --git a/docs/data/core-droprightwhile.md b/docs/data/core-droprightwhile.md index 4be9873..ead9bbc 100644 --- a/docs/data/core-droprightwhile.md +++ b/docs/data/core-droprightwhile.md @@ -4,7 +4,7 @@ slug: droprightwhile sourceRef: slice.go#L486 category: core subCategory: slice -playUrl: https://go.dev/play/p/3-n71oEC0Hz +playUrl: https://go.dev/play/p/HBh8pHl-ZZz variantHelpers: - core#slice#droprightwhile similarHelpers: diff --git a/docs/data/core-dropwhile.md b/docs/data/core-dropwhile.md index eb3a488..e8bd057 100644 --- a/docs/data/core-dropwhile.md +++ b/docs/data/core-dropwhile.md @@ -4,7 +4,7 @@ slug: dropwhile sourceRef: slice.go#L472 category: core subCategory: slice -playUrl: https://go.dev/play/p/7gBPYw2IK16 +playUrl: https://go.dev/play/p/b_PYomVQLGy variantHelpers: - core#slice#dropwhile similarHelpers: diff --git a/docs/data/core-durationx.md b/docs/data/core-durationx.md index 65fae7c..25eac67 100644 --- a/docs/data/core-durationx.md +++ b/docs/data/core-durationx.md @@ -17,7 +17,7 @@ signatures: - "func Duration8[T, U, V, W, X, Y, Z, A any](callback func() (T, U, V, W, X, Y, Z, A)) (T, U, V, W, X, Y, Z, A, time.Duration)" - "func Duration9[T, U, V, W, X, Y, Z, A, B any](callback func() (T, U, V, W, X, Y, Z, A, B)) (T, U, V, W, X, Y, Z, A, B, time.Duration)" - "func Duration10[T, U, V, W, X, Y, Z, A, B, C any](callback func() (T, U, V, W, X, Y, Z, A, B, C)) (T, U, V, W, X, Y, Z, A, B, C, time.Duration)" -playUrl: https://go.dev/play/p/HQfbBbAXaFP +playUrl: https://go.dev/play/p/LFhKq2vY9Ty variantHelpers: - core#time#duration - core#time#durationx diff --git a/docs/data/core-earliest.md b/docs/data/core-earliest.md index 5bc98c8..225a5ed 100644 --- a/docs/data/core-earliest.md +++ b/docs/data/core-earliest.md @@ -4,7 +4,7 @@ slug: earliest sourceRef: find.go#L363 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/pRyy0c6hsBs variantHelpers: - core#find#earliest similarHelpers: diff --git a/docs/data/core-earliestby.md b/docs/data/core-earliestby.md index 889b24d..437db5d 100644 --- a/docs/data/core-earliestby.md +++ b/docs/data/core-earliestby.md @@ -4,7 +4,7 @@ slug: earliestby sourceRef: find.go#L462 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/0XvCF6vuLXC variantHelpers: - core#find#earliestby similarHelpers: diff --git a/docs/data/core-earliestbyerr.md b/docs/data/core-earliestbyerr.md index 57e5164..82a7778 100644 --- a/docs/data/core-earliestbyerr.md +++ b/docs/data/core-earliestbyerr.md @@ -4,6 +4,7 @@ slug: earliestbyerr sourceRef: find.go#L484 category: core subCategory: find +playUrl: https://go.dev/play/p/zJUBUj7ANvq variantHelpers: - core#find#earliestbyerr similarHelpers: diff --git a/docs/data/core-filtererr.md b/docs/data/core-filtererr.md index bd54170..cda2c85 100644 --- a/docs/data/core-filtererr.md +++ b/docs/data/core-filtererr.md @@ -6,7 +6,7 @@ category: core subCategory: slice signatures: - "func FilterErr[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) (bool, error)) (Slice, error)" -playUrl: +playUrl: https://go.dev/play/p/Apjg3WeSi7K variantHelpers: - core#slice#filtererr similarHelpers: diff --git a/docs/data/core-filterkeyserr.md b/docs/data/core-filterkeyserr.md index e7b3ba0..f7ba746 100644 --- a/docs/data/core-filterkeyserr.md +++ b/docs/data/core-filterkeyserr.md @@ -6,7 +6,7 @@ category: core subCategory: map signatures: - "func FilterKeysErr[K comparable, V any](in map[K]V, predicate func(key K, value V) (bool, error)) ([]K, error)" -playUrl: +playUrl: https://go.dev/play/p/j2gUQzCTu4t variantHelpers: - core#map#filterkeyserr similarHelpers: diff --git a/docs/data/core-filtermaptosliceerr.md b/docs/data/core-filtermaptosliceerr.md index 8097eca..c427c8e 100644 --- a/docs/data/core-filtermaptosliceerr.md +++ b/docs/data/core-filtermaptosliceerr.md @@ -6,7 +6,7 @@ category: core subCategory: map signatures: - "func FilterMapToSliceErr[K comparable, V any, R any](in map[K]V, iteratee func(key K, value V) (R, bool, error)) ([]R, error)" -playUrl: +playUrl: https://go.dev/play/p/YjFEORLBWvk variantHelpers: - core#map#filtermaptosliceerr similarHelpers: diff --git a/docs/data/core-filterslicetomap.md b/docs/data/core-filterslicetomap.md index 914fd06..fbd1341 100644 --- a/docs/data/core-filterslicetomap.md +++ b/docs/data/core-filterslicetomap.md @@ -4,7 +4,7 @@ slug: filterslicetomap sourceRef: slice.go#L414 category: core subCategory: slice -playUrl: https://go.dev/play/p/2z0rDz2ZSGU +playUrl: https://go.dev/play/p/eurMiQEqey2 variantHelpers: - core#slice#filterslicetomap similarHelpers: diff --git a/docs/data/core-filtervalueserr.md b/docs/data/core-filtervalueserr.md index d1c5ea3..75cf59c 100644 --- a/docs/data/core-filtervalueserr.md +++ b/docs/data/core-filtervalueserr.md @@ -6,7 +6,7 @@ category: core subCategory: map signatures: - "func FilterValuesErr[K comparable, V any](in map[K]V, predicate func(key K, value V) (bool, error)) ([]V, error)" -playUrl: +playUrl: https://go.dev/play/p/hKvHlqLzbdE variantHelpers: - core#map#filtervalueserr similarHelpers: diff --git a/docs/data/core-findduplicates.md b/docs/data/core-findduplicates.md index c4d745a..ad2796e 100644 --- a/docs/data/core-findduplicates.md +++ b/docs/data/core-findduplicates.md @@ -4,7 +4,7 @@ slug: findduplicates sourceRef: find.go#L207 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/muFgL_XBwoP variantHelpers: - core#find#findduplicates similarHelpers: diff --git a/docs/data/core-findduplicatesby.md b/docs/data/core-findduplicatesby.md index fc3ecba..2d87255 100644 --- a/docs/data/core-findduplicatesby.md +++ b/docs/data/core-findduplicatesby.md @@ -4,7 +4,7 @@ slug: findduplicatesby sourceRef: find.go#L234 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/LKdYdNHuGJG variantHelpers: - core#find#findduplicatesby - core#find#findduplicatesbyerr diff --git a/docs/data/core-findduplicatesbyerr.md b/docs/data/core-findduplicatesbyerr.md index e3171b8..cd970aa 100644 --- a/docs/data/core-findduplicatesbyerr.md +++ b/docs/data/core-findduplicatesbyerr.md @@ -4,6 +4,7 @@ slug: findduplicatesbyerr sourceRef: find.go#L296 category: core subCategory: find +playUrl: https://go.dev/play/p/HiVILQqdFP0 signatures: - "func FindDuplicatesByErr[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) (U, error)) (Slice, error)" variantHelpers: diff --git a/docs/data/core-finderr.md b/docs/data/core-finderr.md index 2bc7c2a..842a064 100644 --- a/docs/data/core-finderr.md +++ b/docs/data/core-finderr.md @@ -6,7 +6,7 @@ category: core subCategory: find signatures: - "func FindErr[T any](collection []T, predicate func(item T) (bool, error)) (T, error)" -playUrl: +playUrl: https://go.dev/play/p/XK-qtpQWXJ9 variantHelpers: [] similarHelpers: - core#find#find diff --git a/docs/data/core-findlastindexof.md b/docs/data/core-findlastindexof.md index a426d7f..81b9e5b 100644 --- a/docs/data/core-findlastindexof.md +++ b/docs/data/core-findlastindexof.md @@ -4,7 +4,7 @@ slug: findlastindexof sourceRef: find.go#L101 category: core subCategory: find -playUrl: https://go.dev/play/p/dPiMRtJ6cUx +playUrl: https://go.dev/play/p/2VhPMiQvX-D variantHelpers: - core#find#findlastindexof similarHelpers: diff --git a/docs/data/core-finduniques.md b/docs/data/core-finduniques.md index 5fb895e..e1b72e2 100644 --- a/docs/data/core-finduniques.md +++ b/docs/data/core-finduniques.md @@ -4,7 +4,7 @@ slug: finduniques sourceRef: find.go#L152 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/NV5vMK_2Z_n variantHelpers: - core#find#finduniques similarHelpers: diff --git a/docs/data/core-finduniquesby.md b/docs/data/core-finduniquesby.md index 467d9cb..71b20f7 100644 --- a/docs/data/core-finduniquesby.md +++ b/docs/data/core-finduniquesby.md @@ -4,7 +4,7 @@ slug: finduniquesby sourceRef: find.go#L178 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/2vmxCs4kW_m variantHelpers: - core#find#finduniquesby similarHelpers: diff --git a/docs/data/core-first.md b/docs/data/core-first.md index 4a904f5..b08c09d 100644 --- a/docs/data/core-first.md +++ b/docs/data/core-first.md @@ -4,7 +4,7 @@ slug: first sourceRef: find.go#L554 category: core subCategory: find -playUrl: https://go.dev/play/p/ul45Z0y2EFO +playUrl: https://go.dev/play/p/94lu5X6_cbf variantHelpers: - core#find#first similarHelpers: diff --git a/docs/data/core-firstor.md b/docs/data/core-firstor.md index fac69e0..da68583 100644 --- a/docs/data/core-firstor.md +++ b/docs/data/core-firstor.md @@ -4,7 +4,7 @@ slug: firstor sourceRef: find.go#L574 category: core subCategory: find -playUrl: https://go.dev/play/p/ul45Z0y2EFO +playUrl: https://go.dev/play/p/x9CxQyRFXeZ variantHelpers: - core#find#firstor similarHelpers: diff --git a/docs/data/core-firstorempty.md b/docs/data/core-firstorempty.md index fe451e3..3bbd941 100644 --- a/docs/data/core-firstorempty.md +++ b/docs/data/core-firstorempty.md @@ -4,7 +4,7 @@ slug: firstorempty sourceRef: find.go#L567 category: core subCategory: find -playUrl: https://go.dev/play/p/ul45Z0y2EFO +playUrl: https://go.dev/play/p/i200n9wgrDA variantHelpers: - core#find#firstorempty similarHelpers: diff --git a/docs/data/core-groupbyerr.md b/docs/data/core-groupbyerr.md index e9dc095..b7fe560 100644 --- a/docs/data/core-groupbyerr.md +++ b/docs/data/core-groupbyerr.md @@ -4,6 +4,7 @@ slug: groupbyerr sourceRef: slice.go#L279 category: core subCategory: slice +playUrl: https://go.dev/play/p/BzKPcY3AdX2 signatures: - "func GroupByErr[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) (U, error)) (map[U]Slice, error)" variantHelpers: diff --git a/docs/data/core-interleave.md b/docs/data/core-interleave.md index 12d6238..05dbdaa 100644 --- a/docs/data/core-interleave.md +++ b/docs/data/core-interleave.md @@ -4,7 +4,7 @@ slug: interleave sourceRef: slice.go#L282 category: core subCategory: slice -playUrl: https://go.dev/play/p/-RJkTLQEDVt +playUrl: https://go.dev/play/p/KOVtGUt-tdI variantHelpers: - core#slice#interleave similarHelpers: diff --git a/docs/data/core-intersectby.md b/docs/data/core-intersectby.md index 7435ba1..68ca255 100644 --- a/docs/data/core-intersectby.md +++ b/docs/data/core-intersectby.md @@ -4,7 +4,7 @@ slug: intersectby sourceRef: intersect.go#L174 category: core subCategory: intersect -playUrl: +playUrl: https://go.dev/play/p/uWF8y2-zmtf variantHelpers: - core#intersect#intersectby similarHelpers: diff --git a/docs/data/core-kebabcase.md b/docs/data/core-kebabcase.md index d48ef8c..0744c11 100644 --- a/docs/data/core-kebabcase.md +++ b/docs/data/core-kebabcase.md @@ -4,7 +4,7 @@ slug: kebabcase sourceRef: string.go#L190 category: core subCategory: string -playUrl: https://go.dev/play/p/96gT_WZnTVP +playUrl: https://go.dev/play/p/ZBeMB4-pq45 variantHelpers: - core#string#kebabcase similarHelpers: diff --git a/docs/data/core-keyify.md b/docs/data/core-keyify.md index f25f7c4..f50bb5c 100644 --- a/docs/data/core-keyify.md +++ b/docs/data/core-keyify.md @@ -4,7 +4,7 @@ slug: keyify sourceRef: slice.go#L429 category: core subCategory: slice -playUrl: https://go.dev/play/p/RYhhM_csqIG +playUrl: https://go.dev/play/p/_d5lXdzfw32 variantHelpers: - core#slice#keyify similarHelpers: diff --git a/docs/data/core-latest.md b/docs/data/core-latest.md index d0695b1..9233315 100644 --- a/docs/data/core-latest.md +++ b/docs/data/core-latest.md @@ -4,7 +4,7 @@ slug: latest sourceRef: find.go#L508 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/dBfdf5s8s-Y variantHelpers: - core#find#latest similarHelpers: diff --git a/docs/data/core-latestby.md b/docs/data/core-latestby.md index cc9f775..f63e7f9 100644 --- a/docs/data/core-latestby.md +++ b/docs/data/core-latestby.md @@ -4,7 +4,7 @@ slug: latestby sourceRef: find.go#L530 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/p1HA8XumaMU variantHelpers: - core#find#latestby similarHelpers: diff --git a/docs/data/core-latestbyerr.md b/docs/data/core-latestbyerr.md index b52ac1f..ab1276b 100644 --- a/docs/data/core-latestbyerr.md +++ b/docs/data/core-latestbyerr.md @@ -4,6 +4,7 @@ slug: latestbyerr sourceRef: find.go#L737 category: core subCategory: find +playUrl: https://go.dev/play/p/WpBUptwnxuG signatures: - "func LatestByErr[T any](collection []T, iteratee func(item T) (time.Time, error)) (T, error)" variantHelpers: diff --git a/docs/data/core-maptoslice.md b/docs/data/core-maptoslice.md index 73c12fd..bf16c86 100644 --- a/docs/data/core-maptoslice.md +++ b/docs/data/core-maptoslice.md @@ -4,7 +4,7 @@ slug: maptoslice sourceRef: map.go#L367 category: core subCategory: map -playUrl: https://go.dev/play/p/ZuiCZpDt6LD +playUrl: https://go.dev/play/p/4f5hbHyMf5h variantHelpers: - core#map#maptoslice similarHelpers: diff --git a/docs/data/core-max.md b/docs/data/core-max.md index 2bfd28e..d47fcd9 100644 --- a/docs/data/core-max.md +++ b/docs/data/core-max.md @@ -4,7 +4,7 @@ slug: max sourceRef: find.go#L410 category: core subCategory: find -playUrl: https://go.dev/play/p/r6e-Z8JozS8 +playUrl: https://go.dev/play/p/wYvG8gRRFw- variantHelpers: - core#find#max similarHelpers: diff --git a/docs/data/core-maxby.md b/docs/data/core-maxby.md index 6d072a5..f5f5785 100644 --- a/docs/data/core-maxby.md +++ b/docs/data/core-maxby.md @@ -4,7 +4,7 @@ slug: maxby sourceRef: find.go#L507 category: core subCategory: find -playUrl: https://go.dev/play/p/JW1qu-ECwF7 +playUrl: https://go.dev/play/p/PJCc-ThrwX1 variantHelpers: - core#find#maxby similarHelpers: diff --git a/docs/data/core-maxbyerr.md b/docs/data/core-maxbyerr.md index f7711ab..649fc10 100644 --- a/docs/data/core-maxbyerr.md +++ b/docs/data/core-maxbyerr.md @@ -4,6 +4,7 @@ slug: maxbyerr sourceRef: find.go#L528 category: core subCategory: find +playUrl: https://go.dev/play/p/s-63-6_9zqM variantHelpers: - core#find#maxbyerr similarHelpers: diff --git a/docs/data/core-maxindex.md b/docs/data/core-maxindex.md index fe687d3..3787043 100644 --- a/docs/data/core-maxindex.md +++ b/docs/data/core-maxindex.md @@ -4,7 +4,7 @@ slug: maxindex sourceRef: find.go#L432 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/RFkB4Mzb1qt variantHelpers: - core#find#maxindex similarHelpers: diff --git a/docs/data/core-maxindexby.md b/docs/data/core-maxindexby.md index f1dc955..c41c383 100644 --- a/docs/data/core-maxindexby.md +++ b/docs/data/core-maxindexby.md @@ -4,7 +4,7 @@ slug: maxindexby sourceRef: find.go#L566 category: core subCategory: find -playUrl: https://go.dev/play/p/uaUszc-c9QK +playUrl: https://go.dev/play/p/5yd4W7pe2QJ variantHelpers: - core#find#maxindexby similarHelpers: diff --git a/docs/data/core-min.md b/docs/data/core-min.md index 94438f4..bfeb528 100644 --- a/docs/data/core-min.md +++ b/docs/data/core-min.md @@ -4,7 +4,7 @@ slug: min sourceRef: find.go#L265 category: core subCategory: find -playUrl: https://go.dev/play/p/r6e-Z8JozS8 +playUrl: https://go.dev/play/p/fJFLwpY8eMN variantHelpers: - core#find#min similarHelpers: diff --git a/docs/data/core-minby.md b/docs/data/core-minby.md index 1adbabc..05667c1 100644 --- a/docs/data/core-minby.md +++ b/docs/data/core-minby.md @@ -4,7 +4,7 @@ slug: minby sourceRef: find.go#L329 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/-B1PsrHVnfx variantHelpers: - core#find#minby similarHelpers: diff --git a/docs/data/core-minbyerr.md b/docs/data/core-minbyerr.md index 1c2d5e0..6b3a70c 100644 --- a/docs/data/core-minbyerr.md +++ b/docs/data/core-minbyerr.md @@ -4,6 +4,7 @@ slug: minbyerr sourceRef: find.go#L349 category: core subCategory: find +playUrl: https://go.dev/play/p/nvDYGS8q895 variantHelpers: - core#find#minbyerr similarHelpers: diff --git a/docs/data/core-minindex.md b/docs/data/core-minindex.md index 5ca821a..fd0992c 100644 --- a/docs/data/core-minindex.md +++ b/docs/data/core-minindex.md @@ -4,7 +4,7 @@ slug: minindex sourceRef: find.go#L287 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/RxAidik4p50 variantHelpers: - core#find#minindex similarHelpers: diff --git a/docs/data/core-minindexby.md b/docs/data/core-minindexby.md index 9488333..a72f543 100644 --- a/docs/data/core-minindexby.md +++ b/docs/data/core-minindexby.md @@ -4,7 +4,7 @@ slug: minindexby sourceRef: find.go#L337 category: core subCategory: find -playUrl: +playUrl: https://go.dev/play/p/zwwPRqWhnUY variantHelpers: - core#find#minindexby similarHelpers: diff --git a/docs/data/core-minindexbyerr.md b/docs/data/core-minindexbyerr.md index 381dda3..b0dc143 100644 --- a/docs/data/core-minindexbyerr.md +++ b/docs/data/core-minindexbyerr.md @@ -4,6 +4,7 @@ slug: minindexbyerr sourceRef: find.go#L404 category: core subCategory: find +playUrl: https://go.dev/play/p/MUqi_NvTKM1 signatures: - "func MinIndexByErr[T any](collection []T, comparison func(a T, b T) (bool, error)) (T, int, error)" variantHelpers: diff --git a/docs/data/core-mode.md b/docs/data/core-mode.md index ef61f2d..2ce6317 100644 --- a/docs/data/core-mode.md +++ b/docs/data/core-mode.md @@ -4,7 +4,7 @@ slug: mode sourceRef: math.go#L149 category: core subCategory: math -playUrl: +playUrl: https://go.dev/play/p/PbiviqnV5zX variantHelpers: - core#math#mode similarHelpers: diff --git a/docs/data/core-newdebounce.md b/docs/data/core-newdebounce.md index f2c2946..4e06993 100644 --- a/docs/data/core-newdebounce.md +++ b/docs/data/core-newdebounce.md @@ -4,7 +4,7 @@ slug: newdebounce sourceRef: retry.go#L54 category: core subCategory: concurrency -playUrl: https://go.dev/play/p/mz32VMK2nqe +playUrl: https://go.dev/play/p/_IPY7ROzbMk variantHelpers: - core#concurrency#newdebounce similarHelpers: diff --git a/docs/data/core-newdebounceby.md b/docs/data/core-newdebounceby.md index 199612c..7f3bd91 100644 --- a/docs/data/core-newdebounceby.md +++ b/docs/data/core-newdebounceby.md @@ -4,7 +4,7 @@ slug: newdebounceby sourceRef: retry.go#L137 category: core subCategory: concurrency -playUrl: https://go.dev/play/p/d3Vpt6pxhY8 +playUrl: https://go.dev/play/p/Izk7GEzZm2Q variantHelpers: - core#concurrency#newdebounceby similarHelpers: diff --git a/docs/data/core-newtransaction.md b/docs/data/core-newtransaction.md index dd91535..a1c8a04 100644 --- a/docs/data/core-newtransaction.md +++ b/docs/data/core-newtransaction.md @@ -4,7 +4,7 @@ slug: newtransaction sourceRef: retry.go#L253 category: core subCategory: concurrency -playUrl: https://go.dev/play/p/Qxrd7MGQGh1 +playUrl: https://go.dev/play/p/7B2o52wEQbj variantHelpers: - core#concurrency#newtransaction similarHelpers: diff --git a/docs/data/core-nth.md b/docs/data/core-nth.md index d1da885..477095c 100644 --- a/docs/data/core-nth.md +++ b/docs/data/core-nth.md @@ -4,7 +4,7 @@ slug: nth sourceRef: find.go#L617 category: core subCategory: find -playUrl: https://go.dev/play/p/sHoh88KWt6B +playUrl: https://go.dev/play/p/mNFI9-kIZZ5 variantHelpers: - core#find#nth similarHelpers: diff --git a/docs/data/core-nthor.md b/docs/data/core-nthor.md index 65c3085..ebe306b 100644 --- a/docs/data/core-nthor.md +++ b/docs/data/core-nthor.md @@ -4,7 +4,7 @@ slug: nthor sourceRef: find.go#L635 category: core subCategory: find -playUrl: https://go.dev/play/p/sHoh88KWt6B +playUrl: https://go.dev/play/p/njKcNhBBVsF variantHelpers: - core#find#nthor similarHelpers: diff --git a/docs/data/core-pascalcase.md b/docs/data/core-pascalcase.md index dff6b29..1a08b96 100644 --- a/docs/data/core-pascalcase.md +++ b/docs/data/core-pascalcase.md @@ -4,7 +4,7 @@ slug: pascalcase sourceRef: string.go#L166 category: core subCategory: string -playUrl: https://go.dev/play/p/Dy_V_6DUYhe +playUrl: https://go.dev/play/p/uxER7XpRHLB variantHelpers: - core#string#pascalcase similarHelpers: diff --git a/docs/data/core-pickbyvalues.md b/docs/data/core-pickbyvalues.md index ceed551..15a3cbc 100644 --- a/docs/data/core-pickbyvalues.md +++ b/docs/data/core-pickbyvalues.md @@ -4,7 +4,7 @@ slug: pickbyvalues sourceRef: map.go#L130 category: core subCategory: map -playUrl: https://go.dev/play/p/1zdzSvbfsJc +playUrl: https://go.dev/play/p/-_PPkSbO1Kc variantHelpers: - core#map#pickbyvalues similarHelpers: diff --git a/docs/data/core-range.md b/docs/data/core-range.md index bb45ce4..171b13c 100644 --- a/docs/data/core-range.md +++ b/docs/data/core-range.md @@ -4,7 +4,7 @@ slug: range sourceRef: math.go#L9 category: core subCategory: math -playUrl: https://go.dev/play/p/0r6VimXAi9H +playUrl: https://go.dev/play/p/rho00R0WuHs variantHelpers: - core#math#range similarHelpers: diff --git a/docs/data/core-rejecterr.md b/docs/data/core-rejecterr.md index 85c7d27..cd2dd11 100644 --- a/docs/data/core-rejecterr.md +++ b/docs/data/core-rejecterr.md @@ -6,7 +6,7 @@ category: core subCategory: slice signatures: - "func RejectErr[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) (bool, error)) (Slice, error)" -playUrl: +playUrl: https://go.dev/play/p/pFCF5WVB225 variantHelpers: - core#slice#rejecterr similarHelpers: diff --git a/docs/data/core-rejectmap.md b/docs/data/core-rejectmap.md index b1e42d8..62c08ca 100644 --- a/docs/data/core-rejectmap.md +++ b/docs/data/core-rejectmap.md @@ -4,7 +4,7 @@ slug: rejectmap sourceRef: slice.go#L550 category: core subCategory: slice -playUrl: https://go.dev/play/p/W9Ug9r0QFk +playUrl: https://go.dev/play/p/bmXhtuM2OMq variantHelpers: - core#slice#rejectmap similarHelpers: diff --git a/docs/data/core-runelength.md b/docs/data/core-runelength.md index fd2a795..8b410c3 100644 --- a/docs/data/core-runelength.md +++ b/docs/data/core-runelength.md @@ -4,7 +4,7 @@ slug: runelength sourceRef: string.go#L160 category: core subCategory: string -playUrl: https://go.dev/play/p/tuhgW_lWY8l +playUrl: https://go.dev/play/p/BXT52mBk0zO variantHelpers: - core#string#runelength similarHelpers: diff --git a/docs/data/core-samples.md b/docs/data/core-samples.md index 5b6baff..4795035 100644 --- a/docs/data/core-samples.md +++ b/docs/data/core-samples.md @@ -4,7 +4,7 @@ slug: samples sourceRef: find.go#L679 category: core subCategory: find -playUrl: https://go.dev/play/p/vCcSJbh5s6l +playUrl: https://go.dev/play/p/QYRD8aufD0C variantHelpers: - core#find#samples similarHelpers: diff --git a/docs/data/core-samplesby.md b/docs/data/core-samplesby.md index f0d0c39..3c70037 100644 --- a/docs/data/core-samplesby.md +++ b/docs/data/core-samplesby.md @@ -4,7 +4,7 @@ slug: samplesby sourceRef: find.go#L686 category: core subCategory: find -playUrl: https://go.dev/play/p/HDmKmMgq0XN +playUrl: https://go.dev/play/p/Dy9bGDhD_Gw variantHelpers: - core#find#samplesby similarHelpers: diff --git a/docs/data/core-shuffle.md b/docs/data/core-shuffle.md index 5ff0f65..630ed76 100644 --- a/docs/data/core-shuffle.md +++ b/docs/data/core-shuffle.md @@ -4,7 +4,7 @@ slug: shuffle sourceRef: slice.go#L322 category: core subCategory: slice -playUrl: https://go.dev/play/p/ZTGG7OUCdnp +playUrl: https://go.dev/play/p/whgrQWwOy-j variantHelpers: - core#slice#shuffle similarHelpers: diff --git a/docs/data/core-sliding.md b/docs/data/core-sliding.md index 1ddf23a..576c932 100644 --- a/docs/data/core-sliding.md +++ b/docs/data/core-sliding.md @@ -6,6 +6,7 @@ category: core subCategory: slice variantHelpers: - core#slice#sliding +playUrl: https://go.dev/play/p/aIIU6gWxl2T similarHelpers: - core#slice#window - core#slice#chunk diff --git a/docs/data/core-substring.md b/docs/data/core-substring.md index 511e8c5..65cb3a3 100644 --- a/docs/data/core-substring.md +++ b/docs/data/core-substring.md @@ -4,7 +4,7 @@ slug: substring sourceRef: string.go#L105 category: core subCategory: string -playUrl: https://go.dev/play/p/TQlxQi82Lu1 +playUrl: https://go.dev/play/p/emzCC9zBjHu variantHelpers: - core#string#substring similarHelpers: diff --git a/docs/data/core-takefilter.md b/docs/data/core-takefilter.md index 240ee1f..69a40d4 100644 --- a/docs/data/core-takefilter.md +++ b/docs/data/core-takefilter.md @@ -6,6 +6,7 @@ category: core subCategory: slice variantHelpers: - core#slice#takefilter +playUrl: https://go.dev/play/p/l99lvN4gReF similarHelpers: - core#slice#filter - core#slice#take diff --git a/docs/data/core-takewhile.md b/docs/data/core-takewhile.md index 6b9a52d..b24937f 100644 --- a/docs/data/core-takewhile.md +++ b/docs/data/core-takewhile.md @@ -6,6 +6,7 @@ category: core subCategory: slice variantHelpers: - core#slice#takewhile +playUrl: https://go.dev/play/p/NJkLGvyRWm4 similarHelpers: - core#slice#take - core#slice#dropwhile diff --git a/docs/data/core-trim.md b/docs/data/core-trim.md index 55f8ee5..7ab7f0c 100644 --- a/docs/data/core-trim.md +++ b/docs/data/core-trim.md @@ -4,7 +4,7 @@ slug: trim sourceRef: slice.go#L842 category: core subCategory: slice -playUrl: https://go.dev/play/p/1an9mxLdRG5 +playUrl: https://go.dev/play/p/LZLfLj5C8Lg variantHelpers: - core#slice#trim similarHelpers: diff --git a/docs/data/core-trimleft.md b/docs/data/core-trimleft.md index 605e546..ca16412 100644 --- a/docs/data/core-trimleft.md +++ b/docs/data/core-trimleft.md @@ -4,7 +4,7 @@ slug: trimleft sourceRef: slice.go#L847 category: core subCategory: slice -playUrl: https://go.dev/play/p/74aqfAYLmyi +playUrl: https://go.dev/play/p/fJK-AhROy9w variantHelpers: - core#slice#trimleft similarHelpers: diff --git a/docs/data/core-trimprefix.md b/docs/data/core-trimprefix.md index 352a8ee..d0758ae 100644 --- a/docs/data/core-trimprefix.md +++ b/docs/data/core-trimprefix.md @@ -4,7 +4,7 @@ slug: trimprefix sourceRef: slice.go#L858 category: core subCategory: slice -playUrl: https://go.dev/play/p/SHO6X-YegPg +playUrl: https://go.dev/play/p/8O2RoWYzi8J variantHelpers: - core#slice#trimprefix similarHelpers: diff --git a/docs/data/core-trimright.md b/docs/data/core-trimright.md index 26e109c..2233812 100644 --- a/docs/data/core-trimright.md +++ b/docs/data/core-trimright.md @@ -4,7 +4,7 @@ slug: trimright sourceRef: slice.go#L873 category: core subCategory: slice -playUrl: https://go.dev/play/p/MRpAfR6sf0g +playUrl: https://go.dev/play/p/9V_N8sRyyiZ variantHelpers: - core#slice#trimright similarHelpers: diff --git a/docs/data/core-tryx.md b/docs/data/core-tryx.md index e05bbad..9cf0e3e 100644 --- a/docs/data/core-tryx.md +++ b/docs/data/core-tryx.md @@ -13,7 +13,7 @@ signatures: - "func Try4[T, R, S any](callback func() (T, R, S, error)) bool" - "func Try5[T, R, S, Q any](callback func() (T, R, S, Q, error)) bool" - "func Try6[T, R, S, Q, U any](callback func() (T, R, S, Q, U, error)) bool" -playUrl: +playUrl: https://go.dev/play/p/mTyyWUvn9u4 variantHelpers: - core#error-handling#try - core#error-handling#tryx diff --git a/docs/data/core-union.md b/docs/data/core-union.md index ce3bb05..ed7647f 100644 --- a/docs/data/core-union.md +++ b/docs/data/core-union.md @@ -4,7 +4,7 @@ slug: union sourceRef: intersect.go#L157 category: core subCategory: intersect -playUrl: https://go.dev/play/p/DI9RVEB_qMK +playUrl: https://go.dev/play/p/-hsqZNTH0ej variantHelpers: - core#intersect#union similarHelpers: diff --git a/docs/data/core-unzipbyerrx.md b/docs/data/core-unzipbyerrx.md index bd54dd5..b3e5143 100644 --- a/docs/data/core-unzipbyerrx.md +++ b/docs/data/core-unzipbyerrx.md @@ -13,6 +13,7 @@ signatures: - "func UnzipByErr7[In any, A any, B any, C any, D any, E any, F any, G any](items []In, predicate func(In) (a A, b B, c C, d D, e E, f F, g G, err error)) ([]A, []B, []C, []D, []E, []F, []G, error)" - "func UnzipByErr8[In any, A any, B any, C any, D any, E any, F any, G any, H any](items []In, predicate func(In) (a A, b B, c C, d D, e E, f F, g G, h H, err error)) ([]A, []B, []C, []D, []E, []F, []G, []H, error)" - "func UnzipByErr9[In any, A any, B any, C any, D any, E any, F any, G any, H any, I any](items []In, predicate func(In) (a A, b B, c C, d D, e E, f F, g G, h H, i I, err error)) ([]A, []B, []C, []D, []E, []F, []G, []H, []I, error)" +playUrl: https://go.dev/play/p/G2pyXQa1SUD variantHelpers: - core#tuple#unzipbyerrx similarHelpers: diff --git a/docs/data/core-unzipx.md b/docs/data/core-unzipx.md index cf53c34..0798c15 100644 --- a/docs/data/core-unzipx.md +++ b/docs/data/core-unzipx.md @@ -13,7 +13,7 @@ signatures: - "func Unzip7[A, B, C, D, E, F, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)" - "func Unzip8[A, B, C, D, E, F, G, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)" - "func Unzip9[A, B, C, D, E, F, G, H, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)" -playUrl: https://go.dev/play/p/ciHugugvaAW +playUrl: https://go.dev/play/p/K-vG9tyD3Kf variantHelpers: - core#tuple#unzipx similarHelpers: diff --git a/docs/data/core-without.md b/docs/data/core-without.md index 63176c1..23cd9ab 100644 --- a/docs/data/core-without.md +++ b/docs/data/core-without.md @@ -4,7 +4,7 @@ slug: without sourceRef: intersect.go#L181 category: core subCategory: intersect -playUrl: https://go.dev/play/p/5j30Ux8TaD0 +playUrl: https://go.dev/play/p/PcAVtYJsEsS variantHelpers: - core#intersect#without similarHelpers: diff --git a/docs/data/core-withoutempty.md b/docs/data/core-withoutempty.md index 43f967f..1b39758 100644 --- a/docs/data/core-withoutempty.md +++ b/docs/data/core-withoutempty.md @@ -4,7 +4,7 @@ slug: withoutempty sourceRef: intersect.go#L218 category: core subCategory: intersect -playUrl: +playUrl: https://go.dev/play/p/iZvYJWuniJm variantHelpers: - core#intersect#withoutempty similarHelpers: diff --git a/docs/data/core-withoutnth.md b/docs/data/core-withoutnth.md index debd0f8..ff5fa83 100644 --- a/docs/data/core-withoutnth.md +++ b/docs/data/core-withoutnth.md @@ -4,7 +4,7 @@ slug: withoutnth sourceRef: intersect.go#L223 category: core subCategory: intersect -playUrl: https://go.dev/play/p/5g3F9R2H1xL +playUrl: https://go.dev/play/p/AIro-_UtL9c variantHelpers: - core#intersect#withoutnth similarHelpers: diff --git a/docs/data/it-buffer.md b/docs/data/it-buffer.md index e7f862d..8a77b32 100644 --- a/docs/data/it-buffer.md +++ b/docs/data/it-buffer.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Buffer[T any](seq iter.Seq[T], size int) iter.Seq[[]T]" -playUrl: "" +playUrl: https://go.dev/play/p/zDZdcCA20ut variantHelpers: - it#sequence#buffer similarHelpers: diff --git a/docs/data/it-chunk.md b/docs/data/it-chunk.md index 0b4af66..9a32b4a 100644 --- a/docs/data/it-chunk.md +++ b/docs/data/it-chunk.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Chunk[T any](collection iter.Seq[T], size int) iter.Seq[[]T]" -playUrl: "https://go.dev/play/p/4VpIM8-zu" +playUrl: https://go.dev/play/p/qo8esZ_L60Q variantHelpers: - it#sequence#chunk similarHelpers: diff --git a/docs/data/it-chunkstring.md b/docs/data/it-chunkstring.md index 7bde820..c8684f6 100644 --- a/docs/data/it-chunkstring.md +++ b/docs/data/it-chunkstring.md @@ -4,7 +4,7 @@ slug: chunkstring sourceRef: it/string.go#L130 category: it subCategory: string -playUrl: "https://go.dev/play/p/Y4mN8bB2cXw" +playUrl: "https://go.dev/play/p/Bcc5ixTQQoQ" variantHelpers: - it#string#chunkstring similarHelpers: diff --git a/docs/data/it-concat.md b/docs/data/it-concat.md index 9a555e4..c55905a 100644 --- a/docs/data/it-concat.md +++ b/docs/data/it-concat.md @@ -4,7 +4,7 @@ slug: concat sourceRef: it/seq.go#L358 category: it subCategory: sequence -playUrl: +playUrl: https://go.dev/play/p/Fa0u7xT2JOR variantHelpers: - it#sequence#concat similarHelpers: diff --git a/docs/data/it-containsby.md b/docs/data/it-containsby.md index e6e20d2..f597b84 100644 --- a/docs/data/it-containsby.md +++ b/docs/data/it-containsby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func ContainsBy[T any](collection iter.Seq[T], predicate func(item T) bool) bool" -playUrl: "https://go.dev/play/p/2edj7hH3TS2" +playUrl: https://go.dev/play/p/m86Cpsoyv8k variantHelpers: - it#intersect#containsby similarHelpers: diff --git a/docs/data/it-count.md b/docs/data/it-count.md index cb7e7bd..482e79e 100644 --- a/docs/data/it-count.md +++ b/docs/data/it-count.md @@ -7,7 +7,7 @@ subCategory: sequence signatures: - "func Count[T comparable](collection iter.Seq[T], value T) int" - "func CountBy[T any](collection iter.Seq[T], predicate func(item T) bool) int" -playUrl: "https://go.dev/play/p/1SmFJ5-zr" +playUrl: https://go.dev/play/p/UcJ-6cANwfY variantHelpers: - it#sequence#count - it#sequence#countby diff --git a/docs/data/it-countby.md b/docs/data/it-countby.md index 8776573..0f149f1 100644 --- a/docs/data/it-countby.md +++ b/docs/data/it-countby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func CountBy[T any](collection iter.Seq[T], predicate func(item T) bool) int" -playUrl: +playUrl: https://go.dev/play/p/m6G0o3huCOG variantHelpers: - it#find#count similarHelpers: diff --git a/docs/data/it-countvalues.md b/docs/data/it-countvalues.md index 91d7c0c..e19d481 100644 --- a/docs/data/it-countvalues.md +++ b/docs/data/it-countvalues.md @@ -6,6 +6,7 @@ category: it subCategory: slice signatures: - "func CountValues[T comparable](collection iter.Seq[T]) map[T]int" +playUrl: https://go.dev/play/p/PPBT4Fp-V3B variantHelpers: [] similarHelpers: - core#slice#countvalues diff --git a/docs/data/it-countvaluesby.md b/docs/data/it-countvaluesby.md index 41638b1..fbe2343 100644 --- a/docs/data/it-countvaluesby.md +++ b/docs/data/it-countvaluesby.md @@ -6,6 +6,7 @@ category: it subCategory: slice signatures: - "func CountValuesBy[T any, U comparable](collection iter.Seq[T], transform func(item T) U) map[U]int" +playUrl: https://go.dev/play/p/gnr_MPhYCHX variantHelpers: [] similarHelpers: - core#slice#countvaluesby diff --git a/docs/data/it-crossjoinbyx.md b/docs/data/it-crossjoinbyx.md index e7e8fe9..0446ddf 100644 --- a/docs/data/it-crossjoinbyx.md +++ b/docs/data/it-crossjoinbyx.md @@ -13,7 +13,7 @@ signatures: - "func CrossJoinBy7[T1, T2, T3, T4, T5, T6, T7, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], transform func(T1, T2, T3, T4, T5, T6, T7) R) iter.Seq[R]" - "func CrossJoinBy8[T1, T2, T3, T4, T5, T6, T7, T8, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], seq8 iter.Seq[T8], transform func(T1, T2, T3, T4, T5, T6, T7, T8) R) iter.Seq[R]" - "func CrossJoinBy9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], seq8 iter.Seq[T8], seq9 iter.Seq[T9], transform func(T1, T2, T3, T4, T5, T6, T7, T8, T9) R) iter.Seq[R]" -playUrl: "https://go.dev/play/p/3XrQKOk-vw" +playUrl: https://go.dev/play/p/6QGp3W-bQU1 variantHelpers: - it#tuple#crossjoinbyx similarHelpers: diff --git a/docs/data/it-crossjoinx.md b/docs/data/it-crossjoinx.md index dd6090e..7f51c59 100644 --- a/docs/data/it-crossjoinx.md +++ b/docs/data/it-crossjoinx.md @@ -13,7 +13,7 @@ signatures: - "func CrossJoin7[T1, T2, T3, T4, T5, T6, T7 any](list1 iter.Seq[T1], list2 iter.Seq[T2], list3 iter.Seq[T3], list4 iter.Seq[T4], list5 iter.Seq[T5], list6 iter.Seq[T6], list7 iter.Seq[T7]) iter.Seq[lo.Tuple7[T1, T2, T3, T4, T5, T6, T7]]" - "func CrossJoin8[T1, T2, T3, T4, T5, T6, T7, T8 any](list1 iter.Seq[T1], list2 iter.Seq[T2], list3 iter.Seq[T3], list4 iter.Seq[T4], list5 iter.Seq[T5], list6 iter.Seq[T6], list7 iter.Seq[T7], list8 iter.Seq[T8]) iter.Seq[lo.Tuple8[T1, T2, T3, T4, T5, T6, T7, T8]]" - "func CrossJoin9[T1, T2, T3, T4, T5, T6, T7, T8, T9 any](list1 iter.Seq[T1], list2 iter.Seq[T2], list3 iter.Seq[T3], list4 iter.Seq[T4], list5 iter.Seq[T5], list6 iter.Seq[T6], list7 iter.Seq[T7], list8 iter.Seq[T8], list9 iter.Seq[T9]) iter.Seq[lo.Tuple9[T1, T2, T3, T4, T5, T6, T7, T8, T9]]" -playUrl: "https://go.dev/play/p/4XrQKOk-vw" +playUrl: https://go.dev/play/p/OFe8xjZFjWU variantHelpers: - it#tuple#crossjoinx similarHelpers: diff --git a/docs/data/it-cutprefix.md b/docs/data/it-cutprefix.md index e9bb386..cfba225 100644 --- a/docs/data/it-cutprefix.md +++ b/docs/data/it-cutprefix.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func CutPrefix[T comparable, I ~func(func(T) bool)](collection I, separator []T) (after I, found bool)" +playUrl: https://go.dev/play/p/bPnV39zVnAV variantHelpers: [] similarHelpers: - core#string#cutprefix diff --git a/docs/data/it-cutsuffix.md b/docs/data/it-cutsuffix.md index 2fe8369..79c150b 100644 --- a/docs/data/it-cutsuffix.md +++ b/docs/data/it-cutsuffix.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func CutSuffix[T comparable, I ~func(func(T) bool)](collection I, separator []T) (before I, found bool)" +playUrl: https://go.dev/play/p/CTRh9m1UHrZ variantHelpers: [] similarHelpers: - core#string#cutsuffix diff --git a/docs/data/it-drain.md b/docs/data/it-drain.md index 3e4fdee..1283b45 100644 --- a/docs/data/it-drain.md +++ b/docs/data/it-drain.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Drain[T any](collection iter.Seq[T])" -playUrl: "https://go.dev/play/p/4eocpKucL-p" +playUrl: https://go.dev/play/p/xU_GCG861r1 variantHelpers: [] similarHelpers: [] position: 170 diff --git a/docs/data/it-drop.md b/docs/data/it-drop.md index df66673..27d70de 100644 --- a/docs/data/it-drop.md +++ b/docs/data/it-drop.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Drop[T any, I ~func(func(T) bool)](collection I, n int) I" -playUrl: "https://go.dev/play/p/1SmFJ5-zr" +playUrl: https://go.dev/play/p/O1J1-uWc3z9 variantHelpers: - it#sequence#drop similarHelpers: diff --git a/docs/data/it-dropbyindex.md b/docs/data/it-dropbyindex.md index 804dee0..2ed742d 100644 --- a/docs/data/it-dropbyindex.md +++ b/docs/data/it-dropbyindex.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func DropByIndex[T any, I ~func(func(T) bool)](collection I, indexes ...int) I" -playUrl: +playUrl: https://go.dev/play/p/vPbrZYgiU4q variantHelpers: - it#slice#drop similarHelpers: diff --git a/docs/data/it-earliest.md b/docs/data/it-earliest.md index 88a6148..eaaf151 100644 --- a/docs/data/it-earliest.md +++ b/docs/data/it-earliest.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Earliest(times iter.Seq[time.Time]) time.Time" -playUrl: "https://go.dev/play/p/7EyYRV1-zd" +playUrl: https://go.dev/play/p/fI6_S10H7Py variantHelpers: - it#find#earliest similarHelpers: diff --git a/docs/data/it-earliestby.md b/docs/data/it-earliestby.md index 42e6472..cd67963 100644 --- a/docs/data/it-earliestby.md +++ b/docs/data/it-earliestby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func EarliestBy[T any](collection iter.Seq[T], transform func(item T) time.Time) T" -playUrl: "https://go.dev/play/p/8FzSW2-ze" +playUrl: https://go.dev/play/p/y_Pf3Jmw-B4 variantHelpers: - it#find#earliestby similarHelpers: diff --git a/docs/data/it-elementsmatch.md b/docs/data/it-elementsmatch.md index f396a8a..8a59181 100644 --- a/docs/data/it-elementsmatch.md +++ b/docs/data/it-elementsmatch.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func ElementsMatch[T comparable](list1, list2 iter.Seq[T]) bool" -playUrl: "https://go.dev/play/p/yGpdBGaWPCA" +playUrl: "https://go.dev/play/p/24SGQm1yMRe" variantHelpers: - it#intersect#elementsmatch similarHelpers: diff --git a/docs/data/it-elementsmatchby.md b/docs/data/it-elementsmatchby.md index d8bbbf5..849de58 100644 --- a/docs/data/it-elementsmatchby.md +++ b/docs/data/it-elementsmatchby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func ElementsMatchBy[T any, K comparable](list1, list2 iter.Seq[T], transform func(item T) K) bool" -playUrl: "https://go.dev/play/p/5XrQKOk-vw" +playUrl: "https://go.dev/play/p/I3vFrmQo43E" variantHelpers: - it#intersect#elementsmatchby similarHelpers: diff --git a/docs/data/it-entries.md b/docs/data/it-entries.md index 1e2d6a0..0e64418 100644 --- a/docs/data/it-entries.md +++ b/docs/data/it-entries.md @@ -6,7 +6,7 @@ category: it subCategory: map signatures: - "func Entries[K comparable, V any](in ...map[K]V) iter.Seq2[K, V]" -playUrl: "https://go.dev/play/p/N8RbJ5t6H2k" +playUrl: https://go.dev/play/p/ckLxqTE9KCz variantHelpers: - it#map#entries similarHelpers: diff --git a/docs/data/it-everyby.md b/docs/data/it-everyby.md index 6db0866..6e866c0 100644 --- a/docs/data/it-everyby.md +++ b/docs/data/it-everyby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func EveryBy[T any](collection iter.Seq[T], predicate func(item T) bool) bool" -playUrl: "https://go.dev/play/p/3edj7hH3TS2" +playUrl: https://go.dev/play/p/7OvV1BRWsER variantHelpers: - it#intersect#everyby similarHelpers: diff --git a/docs/data/it-fill.md b/docs/data/it-fill.md index 34de6a5..a5bcce9 100644 --- a/docs/data/it-fill.md +++ b/docs/data/it-fill.md @@ -7,6 +7,7 @@ subCategory: sequence signatures: - "func Fill[T lo.Clonable[T], I ~func(func(T) bool)](collection I, initial T) I" variantHelpers: [] +playUrl: https://go.dev/play/p/mHShWq5ezMc similarHelpers: - core#slice#fill position: 174 diff --git a/docs/data/it-find.md b/docs/data/it-find.md index 2a344bb..05da65b 100644 --- a/docs/data/it-find.md +++ b/docs/data/it-find.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Find[T any](collection iter.Seq[T], predicate func(item T) bool) (T, bool)" -playUrl: "https://go.dev/play/p/5SdLM6jf-q" +playUrl: https://go.dev/play/p/4w28pF_l58a variantHelpers: - it#find#find similarHelpers: diff --git a/docs/data/it-findduplicates.md b/docs/data/it-findduplicates.md index 04451c4..91fba75 100644 --- a/docs/data/it-findduplicates.md +++ b/docs/data/it-findduplicates.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindDuplicates[T comparable, I ~func(func(T) bool)](collection I) I" -playUrl: "https://go.dev/play/p/1YsRLPl-wx" +playUrl: https://go.dev/play/p/dw-VLQXKijT variantHelpers: - it#find#findduplicates similarHelpers: diff --git a/docs/data/it-findduplicatesby.md b/docs/data/it-findduplicatesby.md index 9885e2c..fe06511 100644 --- a/docs/data/it-findduplicatesby.md +++ b/docs/data/it-findduplicatesby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindDuplicatesBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I" -playUrl: "https://go.dev/play/p/2ZtSMQm-xy" +playUrl: https://go.dev/play/p/tm1tZdC93OH variantHelpers: - it#find#findduplicatesby similarHelpers: diff --git a/docs/data/it-findindexof.md b/docs/data/it-findindexof.md index 33ead4b..1cd526d 100644 --- a/docs/data/it-findindexof.md +++ b/docs/data/it-findindexof.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) (T, int, bool)" -playUrl: "https://go.dev/play/p/6TeNM7kg-r" +playUrl: https://go.dev/play/p/ihchBAEkhXO variantHelpers: - it#find#findindexof similarHelpers: diff --git a/docs/data/it-findlastindexof.md b/docs/data/it-findlastindexof.md index 259fe27..f38b77b 100644 --- a/docs/data/it-findlastindexof.md +++ b/docs/data/it-findlastindexof.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindLastIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) (T, int, bool)" -playUrl: "https://go.dev/play/p/7UfON8lh-s" +playUrl: https://go.dev/play/p/ezz6hXaC4Md variantHelpers: - it#find#findlastindexof similarHelpers: diff --git a/docs/data/it-findorelse.md b/docs/data/it-findorelse.md index 41c58d6..c0f2802 100644 --- a/docs/data/it-findorelse.md +++ b/docs/data/it-findorelse.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindOrElse[T any](collection iter.Seq[T], fallback T, predicate func(item T) bool) T" -playUrl: "https://go.dev/play/p/8VgPO9mi-t" +playUrl: https://go.dev/play/p/1harvaiGMfI variantHelpers: - it#find#findorelse similarHelpers: diff --git a/docs/data/it-finduniques.md b/docs/data/it-finduniques.md index c176873..42ffb6f 100644 --- a/docs/data/it-finduniques.md +++ b/docs/data/it-finduniques.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindUniques[T comparable, I ~func(func(T) bool)](collection I) I" -playUrl: "https://go.dev/play/p/9WhQPJnj-u" +playUrl: https://go.dev/play/p/O8dwXEbT56F variantHelpers: - it#find#finduniques similarHelpers: diff --git a/docs/data/it-finduniquesby.md b/docs/data/it-finduniquesby.md index 1148676..90c3b8e 100644 --- a/docs/data/it-finduniquesby.md +++ b/docs/data/it-finduniquesby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FindUniquesBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I" -playUrl: "https://go.dev/play/p/0XrQKOk-vw" +playUrl: https://go.dev/play/p/TiwGIzeDuML variantHelpers: - it#find#finduniquesby similarHelpers: diff --git a/docs/data/it-first.md b/docs/data/it-first.md index 542d871..0ca90f4 100644 --- a/docs/data/it-first.md +++ b/docs/data/it-first.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func First[T any](collection iter.Seq[T]) (T, bool)" -playUrl: "https://go.dev/play/p/5MgZD9-zl" +playUrl: https://go.dev/play/p/EhNyrc8jPfY variantHelpers: - it#find#first similarHelpers: diff --git a/docs/data/it-firstor.md b/docs/data/it-firstor.md index 2f01797..3bd1873 100644 --- a/docs/data/it-firstor.md +++ b/docs/data/it-firstor.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FirstOr[T any](collection iter.Seq[T], fallback T) T" -playUrl: "https://go.dev/play/p/7OiBF1-zn" +playUrl: https://go.dev/play/p/wGFXI5NHkE2 variantHelpers: - it#find#firstor similarHelpers: diff --git a/docs/data/it-firstorempty.md b/docs/data/it-firstorempty.md index bd7b5a0..54e8974 100644 --- a/docs/data/it-firstorempty.md +++ b/docs/data/it-firstorempty.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func FirstOrEmpty[T any](collection iter.Seq[T]) T" -playUrl: "https://go.dev/play/p/6NhAE0-zm" +playUrl: https://go.dev/play/p/NTUTgPCfevx variantHelpers: - it#find#firstorempty similarHelpers: diff --git a/docs/data/it-flatmap.md b/docs/data/it-flatmap.md index e27d1fb..cf64269 100644 --- a/docs/data/it-flatmap.md +++ b/docs/data/it-flatmap.md @@ -7,7 +7,7 @@ subCategory: sequence signatures: - "func FlatMap[T, R any](collection iter.Seq[T], transform func(item T) iter.Seq[R]) iter.Seq[R]" - "func FlatMapI[T, R any](collection iter.Seq[T], transform func(item T, index int) iter.Seq[R]) iter.Seq[R]" -playUrl: "https://go.dev/play/p/1YsRLPl-wx" +playUrl: https://go.dev/play/p/6toB9w2gpSy variantHelpers: - it#sequence#flatmap - it#sequence#flatmapi diff --git a/docs/data/it-flatten.md b/docs/data/it-flatten.md index ca20c69..956081b 100644 --- a/docs/data/it-flatten.md +++ b/docs/data/it-flatten.md @@ -7,6 +7,7 @@ subCategory: sequence signatures: - "func Flatten[T any, I ~func(func(T) bool)](collection []I) I" variantHelpers: [] +playUrl: https://go.dev/play/p/CCklxuNk7Lm similarHelpers: - core#slice#flatten position: 172 diff --git a/docs/data/it-fromanyseq.md b/docs/data/it-fromanyseq.md index f31528c..2464881 100644 --- a/docs/data/it-fromanyseq.md +++ b/docs/data/it-fromanyseq.md @@ -8,6 +8,7 @@ signatures: - "func FromAnySeq[T any](collection iter.Seq[any]) iter.Seq[T]" variantHelpers: - it#type#toanyseq +playUrl: "https://go.dev/play/p/wnOma1j5Uzu" similarHelpers: - core#type#fromany position: 244 diff --git a/docs/data/it-fromentries.md b/docs/data/it-fromentries.md index 56d73ef..5f8c320 100644 --- a/docs/data/it-fromentries.md +++ b/docs/data/it-fromentries.md @@ -6,7 +6,7 @@ category: it subCategory: map signatures: - "func FromEntries[K comparable, V any](entries ...iter.Seq2[K, V]) map[K]V" -playUrl: "https://go.dev/play/p/K3wL9j7TmXs" +playUrl: https://go.dev/play/p/MgEF1J5-tuK variantHelpers: - it#map#fromentries - it#map#frompairs diff --git a/docs/data/it-fromseqptr.md b/docs/data/it-fromseqptr.md index fed1b77..3d35d63 100644 --- a/docs/data/it-fromseqptr.md +++ b/docs/data/it-fromseqptr.md @@ -8,6 +8,7 @@ signatures: - "func FromSeqPtr[T any](collection iter.Seq[*T]) iter.Seq[T]" variantHelpers: - it#type#fromseqptror +playUrl: "https://go.dev/play/p/_eO6scpLcBF" similarHelpers: - core#type#fromptr position: 241 diff --git a/docs/data/it-fromseqptror.md b/docs/data/it-fromseqptror.md index 406a723..f9453dc 100644 --- a/docs/data/it-fromseqptror.md +++ b/docs/data/it-fromseqptror.md @@ -8,6 +8,7 @@ signatures: - "func FromSeqPtrOr[T any](collection iter.Seq[*T], fallback T) iter.Seq[T]" variantHelpers: - it#type#fromseqptr +playUrl: "https://go.dev/play/p/LJ17S4pvOjo" similarHelpers: [] position: 242 --- diff --git a/docs/data/it-groupby.md b/docs/data/it-groupby.md index 7aa5358..4a2f718 100644 --- a/docs/data/it-groupby.md +++ b/docs/data/it-groupby.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func GroupBy[T any, U comparable](collection iter.Seq[T], transform func(item T) U) map[U][]T" -playUrl: "https://go.dev/play/p/2TnGK6-zs" +playUrl: https://go.dev/play/p/oRIakS89OYy variantHelpers: - it#sequence#groupby similarHelpers: diff --git a/docs/data/it-hasprefix.md b/docs/data/it-hasprefix.md index 9773afa..391fa7a 100644 --- a/docs/data/it-hasprefix.md +++ b/docs/data/it-hasprefix.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func HasPrefix[T comparable](collection iter.Seq[T], prefix ...T) bool" -playUrl: "https://go.dev/play/p/3QbJK4hd-o" +playUrl: https://go.dev/play/p/Fyj6uq-G5IH variantHelpers: - it#find#hasprefix similarHelpers: diff --git a/docs/data/it-hassuffix.md b/docs/data/it-hassuffix.md index c22b444..cf495b4 100644 --- a/docs/data/it-hassuffix.md +++ b/docs/data/it-hassuffix.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func HasSuffix[T comparable](collection iter.Seq[T], suffix ...T) bool" -playUrl: "https://go.dev/play/p/4RcKL5ie-p" +playUrl: https://go.dev/play/p/r6bF9Rmq5S0 variantHelpers: - it#find#hassuffix similarHelpers: diff --git a/docs/data/it-interleave.md b/docs/data/it-interleave.md index 294115f..7abbea1 100644 --- a/docs/data/it-interleave.md +++ b/docs/data/it-interleave.md @@ -7,6 +7,7 @@ subCategory: sequence signatures: - "func Interleave[T any](collections ...iter.Seq[T]) iter.Seq[T]" variantHelpers: [] +playUrl: https://go.dev/play/p/kNvnz4ClLgH similarHelpers: - core#slice#interleave position: 173 diff --git a/docs/data/it-intersectby.md b/docs/data/it-intersectby.md index 3ca0b03..be518d1 100644 --- a/docs/data/it-intersectby.md +++ b/docs/data/it-intersectby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func IntersectBy[T any, K comparable, I ~func(func(T) bool)](func(T) K, lists ...I) I" -playUrl: +playUrl: https://go.dev/play/p/X2nEvHC-lE2 variantHelpers: - it#intersect#intersectby similarHelpers: diff --git a/docs/data/it-invert.md b/docs/data/it-invert.md index 905d525..bfb1755 100644 --- a/docs/data/it-invert.md +++ b/docs/data/it-invert.md @@ -6,7 +6,7 @@ category: it subCategory: map signatures: - "func Invert[K, V comparable](in iter.Seq2[K, V]) iter.Seq2[V, K]" -playUrl: "https://go.dev/play/p/H4jR7n2sF8k" +playUrl: https://go.dev/play/p/Iph19Lgcsx- variantHelpers: - it#map#invert similarHelpers: diff --git a/docs/data/it-isempty.md b/docs/data/it-isempty.md index dfcf745..790656d 100644 --- a/docs/data/it-isempty.md +++ b/docs/data/it-isempty.md @@ -6,7 +6,7 @@ category: it subCategory: type signatures: - "func IsEmpty[T any](collection iter.Seq[T]) bool" -playUrl: "https://go.dev/play/p/F6gG2iI9Cd4" +playUrl: https://go.dev/play/p/krZ-laaVi2C variantHelpers: - it#type#isempty similarHelpers: diff --git a/docs/data/it-issorted.md b/docs/data/it-issorted.md index 92e13e6..7a4c18a 100644 --- a/docs/data/it-issorted.md +++ b/docs/data/it-issorted.md @@ -6,6 +6,7 @@ category: it subCategory: slice signatures: - "func IsSorted[T constraints.Ordered](collection iter.Seq[T]) bool" +playUrl: https://go.dev/play/p/o-BD4UOn-0U variantHelpers: [] similarHelpers: - core#slice#issorted diff --git a/docs/data/it-issortedby.md b/docs/data/it-issortedby.md index 84a928a..cc0cf61 100644 --- a/docs/data/it-issortedby.md +++ b/docs/data/it-issortedby.md @@ -6,6 +6,7 @@ category: it subCategory: slice signatures: - "func IsSortedBy[T any, K constraints.Ordered](collection iter.Seq[T], transform func(item T) K) bool" +playUrl: https://go.dev/play/p/AfYOiGWa78T variantHelpers: [] similarHelpers: - core#slice#issortedby diff --git a/docs/data/it-keyby.md b/docs/data/it-keyby.md index 73696ea..242c248 100644 --- a/docs/data/it-keyby.md +++ b/docs/data/it-keyby.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func KeyBy[K comparable, V any](collection iter.Seq[V], transform func(item V) K) map[K]V" -playUrl: +playUrl: https://go.dev/play/p/MMaHpzTqY0a variantHelpers: - it#map#associate similarHelpers: diff --git a/docs/data/it-keyify.md b/docs/data/it-keyify.md index 6e126db..f3c1167 100644 --- a/docs/data/it-keyify.md +++ b/docs/data/it-keyify.md @@ -6,6 +6,7 @@ category: it subCategory: slice signatures: - "func Keyify[T comparable](collection iter.Seq[T]) map[T]struct{}" +playUrl: https://go.dev/play/p/aHOD29_l-rF variantHelpers: [] similarHelpers: - core#slice#keyby diff --git a/docs/data/it-last.md b/docs/data/it-last.md index a90a608..b272c4a 100644 --- a/docs/data/it-last.md +++ b/docs/data/it-last.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Last[T any](collection iter.Seq[T]) (T, bool)" -playUrl: https://go.dev/play/p/8PjCG2-zo +playUrl: https://go.dev/play/p/eGZV-sSmn_Q variantHelpers: - it#find#last similarHelpers: diff --git a/docs/data/it-lastindexof.md b/docs/data/it-lastindexof.md index 10ad600..d0829ba 100644 --- a/docs/data/it-lastindexof.md +++ b/docs/data/it-lastindexof.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func LastIndexOf[T comparable](collection iter.Seq[T], element T) int" -playUrl: "https://go.dev/play/p/2PaIZ3gc-n" +playUrl: https://go.dev/play/p/QPATR3VC5wT variantHelpers: - it#find#lastindexof similarHelpers: diff --git a/docs/data/it-lastor.md b/docs/data/it-lastor.md index 4373a5c..a7a12e1 100644 --- a/docs/data/it-lastor.md +++ b/docs/data/it-lastor.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func LastOr[T any](collection iter.Seq[T], fallback T) T" -playUrl: "https://go.dev/play/p/0RlEI4-zq" +playUrl: https://go.dev/play/p/HNubjW2Mrxs variantHelpers: - it#find#lastor similarHelpers: diff --git a/docs/data/it-lastorempty.md b/docs/data/it-lastorempty.md index 3e4e290..26af974 100644 --- a/docs/data/it-lastorempty.md +++ b/docs/data/it-lastorempty.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func LastOrEmpty[T any](collection iter.Seq[T]) T" -playUrl: "https://go.dev/play/p/9QkDH3-zp" +playUrl: https://go.dev/play/p/teODFK4YqM4 variantHelpers: - it#find#lastorempty similarHelpers: diff --git a/docs/data/it-latest.md b/docs/data/it-latest.md index 4da4465..c5273a9 100644 --- a/docs/data/it-latest.md +++ b/docs/data/it-latest.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Latest(times iter.Seq[time.Time]) time.Time" -playUrl: "https://go.dev/play/p/3KeXB7-zj" +playUrl: https://go.dev/play/p/r5Yq6ATSHoH variantHelpers: - it#find#latest similarHelpers: diff --git a/docs/data/it-latestby.md b/docs/data/it-latestby.md index c9fad5c..5e5708f 100644 --- a/docs/data/it-latestby.md +++ b/docs/data/it-latestby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func LatestBy[T any](collection iter.Seq[T], transform func(item T) time.Time) T" -playUrl: "https://go.dev/play/p/4LfYC8-zk" +playUrl: https://go.dev/play/p/o_daRzHrDUU variantHelpers: - it#find#latestby similarHelpers: diff --git a/docs/data/it-max.md b/docs/data/it-max.md index 12bf706..49f1d90 100644 --- a/docs/data/it-max.md +++ b/docs/data/it-max.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Max[T constraints.Ordered](collection iter.Seq[T]) T" -playUrl: "https://go.dev/play/p/9GaTX3-zf" +playUrl: https://go.dev/play/p/C2ZtW2bsBZ6 variantHelpers: - it#find#max similarHelpers: diff --git a/docs/data/it-maxby.md b/docs/data/it-maxby.md index 1fae11c..3783fba 100644 --- a/docs/data/it-maxby.md +++ b/docs/data/it-maxby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MaxBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T" -playUrl: "https://go.dev/play/p/1IcVZ5-zh" +playUrl: https://go.dev/play/p/yBhXFJb5oxC variantHelpers: - it#find#maxby similarHelpers: diff --git a/docs/data/it-maxindex.md b/docs/data/it-maxindex.md index 44ad08c..d0b117f 100644 --- a/docs/data/it-maxindex.md +++ b/docs/data/it-maxindex.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MaxIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int)" -playUrl: "https://go.dev/play/p/0HbUY4-zg" +playUrl: https://go.dev/play/p/zeu2wUvhl5e variantHelpers: - it#find#maxindex similarHelpers: diff --git a/docs/data/it-maxindexby.md b/docs/data/it-maxindexby.md index 1988ecd..d1d3d67 100644 --- a/docs/data/it-maxindexby.md +++ b/docs/data/it-maxindexby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MaxIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, int)" -playUrl: "https://go.dev/play/p/2JdWA6-zi" +playUrl: https://go.dev/play/p/MXyE6BTILjx variantHelpers: - it#find#maxindexby similarHelpers: diff --git a/docs/data/it-meanby.md b/docs/data/it-meanby.md index 8624def..e0012d0 100644 --- a/docs/data/it-meanby.md +++ b/docs/data/it-meanby.md @@ -6,7 +6,7 @@ category: it subCategory: math signatures: - "func MeanBy[T any, R constraints.Float | constraints.Integer](collection iter.Seq[T], transform func(item T) R) R" -playUrl: +playUrl: https://go.dev/play/p/Ked4rpztH5Y variantHelpers: - it#math#mean similarHelpers: diff --git a/docs/data/it-min.md b/docs/data/it-min.md index 86202f8..3072db0 100644 --- a/docs/data/it-min.md +++ b/docs/data/it-min.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Min[T constraints.Ordered](collection iter.Seq[T]) T" -playUrl: "https://go.dev/play/p/3AuTNRn-yz" +playUrl: https://go.dev/play/p/0VihyYEaM-M variantHelpers: - it#find#min similarHelpers: diff --git a/docs/data/it-minby.md b/docs/data/it-minby.md index a73ebfe..0f1cf87 100644 --- a/docs/data/it-minby.md +++ b/docs/data/it-minby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MinBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T" -playUrl: "https://go.dev/play/p/5CwPTPz-zb" +playUrl: https://go.dev/play/p/J5koo8khN-g variantHelpers: - it#find#minby similarHelpers: diff --git a/docs/data/it-minindex.md b/docs/data/it-minindex.md index 58e1a61..880e631 100644 --- a/docs/data/it-minindex.md +++ b/docs/data/it-minindex.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MinIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int)" -playUrl: "https://go.dev/play/p/4BvOSo-yza" +playUrl: https://go.dev/play/p/70ncPxECj6l variantHelpers: - it#find#minindex similarHelpers: diff --git a/docs/data/it-minindexby.md b/docs/data/it-minindexby.md index d529d27..c309c8a 100644 --- a/docs/data/it-minindexby.md +++ b/docs/data/it-minindexby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func MinIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, int)" -playUrl: "https://go.dev/play/p/6DxQUQ0-zc" +playUrl: https://go.dev/play/p/blldzWJpqVa variantHelpers: - it#find#minindexby similarHelpers: diff --git a/docs/data/it-none.md b/docs/data/it-none.md index bc0677a..cbd6551 100644 --- a/docs/data/it-none.md +++ b/docs/data/it-none.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func None[T comparable](collection iter.Seq[T], subset ...T) bool" -playUrl: "https://go.dev/play/p/KmX-fXictQl" +playUrl: "https://go.dev/play/p/L7mm5S4a8Yo" variantHelpers: - it#intersect#none similarHelpers: diff --git a/docs/data/it-noneby.md b/docs/data/it-noneby.md index 62f40e6..035bbad 100644 --- a/docs/data/it-noneby.md +++ b/docs/data/it-noneby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func NoneBy[T any](collection iter.Seq[T], predicate func(item T) bool) bool" -playUrl: "https://go.dev/play/p/4edj7hH3TS2" +playUrl: https://go.dev/play/p/PR7ddQ7Ckz5 variantHelpers: - it#intersect#noneby similarHelpers: diff --git a/docs/data/it-nth.md b/docs/data/it-nth.md index fb94908..a98a054 100644 --- a/docs/data/it-nth.md +++ b/docs/data/it-nth.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Nth[T any, N constraints.Integer](collection iter.Seq[T], nth N) (T, error)" -playUrl: https://go.dev/play/p/1SmFJ5-zr +playUrl: https://go.dev/play/p/FqgCobsKqva variantHelpers: - it#find#nth similarHelpers: diff --git a/docs/data/it-nthor.md b/docs/data/it-nthor.md index ce3fb96..fe5eadd 100644 --- a/docs/data/it-nthor.md +++ b/docs/data/it-nthor.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func NthOr[T any, N constraints.Integer](collection iter.Seq[T], nth N, fallback T) T" -playUrl: "https://go.dev/play/p/2TnGK6-zs" +playUrl: https://go.dev/play/p/MNweuhpy4Ym variantHelpers: - it#find#nthor similarHelpers: diff --git a/docs/data/it-nthorempty.md b/docs/data/it-nthorempty.md index 5e4e9b0..107c904 100644 --- a/docs/data/it-nthorempty.md +++ b/docs/data/it-nthorempty.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func NthOrEmpty[T any, N constraints.Integer](collection iter.Seq[T], nth N) T" -playUrl: "https://go.dev/play/p/3UoHL7-zt" +playUrl: https://go.dev/play/p/pC0Zhu3EUhe variantHelpers: - it#find#nthorempty similarHelpers: diff --git a/docs/data/it-partitionby.md b/docs/data/it-partitionby.md index 4bae736..319093d 100644 --- a/docs/data/it-partitionby.md +++ b/docs/data/it-partitionby.md @@ -7,6 +7,7 @@ subCategory: sequence signatures: - "func PartitionBy[T any, K comparable](collection iter.Seq[T], transform func(item T) K) [][]T" variantHelpers: [] +playUrl: https://go.dev/play/p/VxTx8mva28z similarHelpers: - core#slice#partitionby position: 171 diff --git a/docs/data/it-product.md b/docs/data/it-product.md index b14b1cc..4b7f468 100644 --- a/docs/data/it-product.md +++ b/docs/data/it-product.md @@ -7,7 +7,7 @@ subCategory: math signatures: - "func Product[T constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T]) T" - "func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T], iteratee func(item T) R) R" -playUrl: "https://go.dev/play/p/ebgxKxJmhLj" +playUrl: "https://go.dev/play/p/AOMCD1Yl5Bc" variantHelpers: - it#math#product - it#math#productby diff --git a/docs/data/it-productby.md b/docs/data/it-productby.md index 0d6db80..7b5efb8 100644 --- a/docs/data/it-productby.md +++ b/docs/data/it-productby.md @@ -6,7 +6,7 @@ category: it subCategory: math signatures: - "func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T], transform func(item T) R) R" -playUrl: +playUrl: "https://go.dev/play/p/dgFCRJrlPHY" variantHelpers: - it#math#product similarHelpers: diff --git a/docs/data/it-range.md b/docs/data/it-range.md index 7207f47..167cb56 100644 --- a/docs/data/it-range.md +++ b/docs/data/it-range.md @@ -6,7 +6,7 @@ category: it subCategory: math signatures: - "func Range(elementNum int) iter.Seq[int]" -playUrl: "https://go.dev/play/p/6ksL0W6KEuQ" +playUrl: "https://go.dev/play/p/79QUZBa8Ukn" variantHelpers: - it#math#range similarHelpers: diff --git a/docs/data/it-reducelast.md b/docs/data/it-reducelast.md index f0c7297..c33107a 100644 --- a/docs/data/it-reducelast.md +++ b/docs/data/it-reducelast.md @@ -7,7 +7,7 @@ subCategory: sequence signatures: - "func ReduceLast[T, R any](collection iter.Seq[T], accumulator func(agg R, item T) R, initial R) R" - "func ReduceLastI[T, R any](collection iter.Seq[T], accumulator func(agg R, item T, index int) R, initial R) R" -playUrl: +playUrl: https://go.dev/play/p/D2ZGZ2pN270 variantHelpers: - it#sequence#reduce - it#sequence#reducei diff --git a/docs/data/it-repeat.md b/docs/data/it-repeat.md index 092a0cf..0ead497 100644 --- a/docs/data/it-repeat.md +++ b/docs/data/it-repeat.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Repeat[T lo.Clonable[T]](count int, initial T) iter.Seq[T]" -playUrl: +playUrl: https://go.dev/play/p/xs-aq0p_uDP variantHelpers: - it#slice#repeatby similarHelpers: diff --git a/docs/data/it-repeatby.md b/docs/data/it-repeatby.md index e1c018a..0efa68e 100644 --- a/docs/data/it-repeatby.md +++ b/docs/data/it-repeatby.md @@ -6,6 +6,7 @@ category: it subCategory: sequence signatures: - "func RepeatBy[T any](count int, callback func(index int) T) iter.Seq[T]" +playUrl: https://go.dev/play/p/i7BuZQBcUzZ variantHelpers: - it#sequence#repeatby similarHelpers: diff --git a/docs/data/it-reverse.md b/docs/data/it-reverse.md index 2498e1a..0281cad 100644 --- a/docs/data/it-reverse.md +++ b/docs/data/it-reverse.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Reverse[T any, I ~func(func(T) bool)](collection I) I" -playUrl: https://go.dev/play/p/9jthUzgF-u +playUrl: https://go.dev/play/p/R6-lR8yiNwa variantHelpers: - it#sequence#reverse similarHelpers: diff --git a/docs/data/it-sample.md b/docs/data/it-sample.md index 869261c..99c6d72 100644 --- a/docs/data/it-sample.md +++ b/docs/data/it-sample.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Sample[T any](collection iter.Seq[T]) T" -playUrl: "https://go.dev/play/p/4VpIM8-zu" +playUrl: https://go.dev/play/p/YDJVX0UXYDi variantHelpers: - it#find#sample similarHelpers: diff --git a/docs/data/it-sampleby.md b/docs/data/it-sampleby.md index 412b325..720245a 100644 --- a/docs/data/it-sampleby.md +++ b/docs/data/it-sampleby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func SampleBy[T any](collection iter.Seq[T], randomIntGenerator func(int) int) T" -playUrl: "https://go.dev/play/p/5WqJN9-zv" +playUrl: https://go.dev/play/p/QQooySxORib variantHelpers: - it#find#sampleby similarHelpers: diff --git a/docs/data/it-samples.md b/docs/data/it-samples.md index 4426ed1..f25ff37 100644 --- a/docs/data/it-samples.md +++ b/docs/data/it-samples.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func Samples[T any, I ~func(func(T) bool)](collection I, count int) I" -playUrl: "https://go.dev/play/p/6XrKO0-zw" +playUrl: https://go.dev/play/p/GUTFx9LQ8pP variantHelpers: - it#find#samples similarHelpers: diff --git a/docs/data/it-samplesby.md b/docs/data/it-samplesby.md index 1e8fa7e..038a1b8 100644 --- a/docs/data/it-samplesby.md +++ b/docs/data/it-samplesby.md @@ -6,7 +6,7 @@ category: it subCategory: find signatures: - "func SamplesBy[T any, I ~func(func(T) bool)](collection I, count int, randomIntGenerator func(int) int) I" -playUrl: "https://go.dev/play/p/7YsLP1-zx" +playUrl: https://go.dev/play/p/fX2FEtixrVG variantHelpers: - it#find#samplesby similarHelpers: diff --git a/docs/data/it-shuffle.md b/docs/data/it-shuffle.md index a00b5b2..8f1e92e 100644 --- a/docs/data/it-shuffle.md +++ b/docs/data/it-shuffle.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Shuffle[T any, I ~func(func(T) bool)](collection I) I" -playUrl: https://go.dev/play/p/8isgTsyfL-t +playUrl: https://go.dev/play/p/3WOx-ukGvKK variantHelpers: - it#sequence#shuffle similarHelpers: diff --git a/docs/data/it-sliding.md b/docs/data/it-sliding.md index 5d4bf23..dfb6816 100644 --- a/docs/data/it-sliding.md +++ b/docs/data/it-sliding.md @@ -6,6 +6,7 @@ category: it subCategory: sequence signatures: - "func Sliding[T any](collection iter.Seq[T], size, step int) iter.Seq[[]T]" +playUrl: https://go.dev/play/p/mzhO4CZeiik variantHelpers: - it#sequence#sliding similarHelpers: diff --git a/docs/data/it-someby.md b/docs/data/it-someby.md index b31d315..db78966 100644 --- a/docs/data/it-someby.md +++ b/docs/data/it-someby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func SomeBy[T any](collection iter.Seq[T], predicate func(item T) bool) bool" -playUrl: "https://go.dev/play/p/5edj7hH3TS2" +playUrl: https://go.dev/play/p/PDT6dWCl7Md variantHelpers: - it#intersect#someby similarHelpers: diff --git a/docs/data/it-sumby.md b/docs/data/it-sumby.md index 6e8d2bc..e3d68ed 100644 --- a/docs/data/it-sumby.md +++ b/docs/data/it-sumby.md @@ -6,7 +6,7 @@ category: it subCategory: math signatures: - "func SumBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T], transform func(item T) R) R" -playUrl: +playUrl: https://go.dev/play/p/ZNiqXNMu5QP variantHelpers: - it#math#sumby similarHelpers: diff --git a/docs/data/it-takefilter.md b/docs/data/it-takefilter.md index 7c7e214..448448a 100644 --- a/docs/data/it-takefilter.md +++ b/docs/data/it-takefilter.md @@ -7,6 +7,7 @@ subCategory: sequence signatures: - "func TakeFilter[T any, I ~func(func(T) bool)](collection I, n int, predicate func(item T) bool) I" - "func TakeFilterI[T any, I ~func(func(T) bool)](collection I, n int, predicate func(item T, index int) bool) I" +playUrl: https://go.dev/play/p/Db68Bhu4MCA variantHelpers: - it#sequence#takefilter - it#sequence#takefilteri diff --git a/docs/data/it-times.md b/docs/data/it-times.md index 7dfb306..ad339df 100644 --- a/docs/data/it-times.md +++ b/docs/data/it-times.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Times[T any](count int, callback func(index int) T) iter.Seq[T]" -playUrl: "https://go.dev/play/p/9QkDH3-zp" +playUrl: https://go.dev/play/p/0W4IRzQuCEc variantHelpers: - it#sequence#times similarHelpers: diff --git a/docs/data/it-toanyseq.md b/docs/data/it-toanyseq.md index 7e5cce2..9e38a7b 100644 --- a/docs/data/it-toanyseq.md +++ b/docs/data/it-toanyseq.md @@ -8,6 +8,7 @@ signatures: - "func ToAnySeq[T any](collection iter.Seq[T]) iter.Seq[any]" variantHelpers: - it#type#fromanyseq +playUrl: "https://go.dev/play/p/ktE4IMXDMxv" similarHelpers: - core#type#toany position: 243 diff --git a/docs/data/it-toseqptr.md b/docs/data/it-toseqptr.md index af00803..08ab99f 100644 --- a/docs/data/it-toseqptr.md +++ b/docs/data/it-toseqptr.md @@ -6,6 +6,7 @@ category: it subCategory: type signatures: - "func ToSeqPtr[T any](collection iter.Seq[T]) iter.Seq[*T]" +playUrl: "https://go.dev/play/p/70BcKpDcOKm" variantHelpers: [] similarHelpers: - core#type#toptr diff --git a/docs/data/it-trim.md b/docs/data/it-trim.md index 431015b..8753e50 100644 --- a/docs/data/it-trim.md +++ b/docs/data/it-trim.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func Trim[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I" +playUrl: https://go.dev/play/p/k0VCcilk4V1 variantHelpers: - it#string#trimfirst - it#string#trimlast diff --git a/docs/data/it-trimfirst.md b/docs/data/it-trimfirst.md index eda01f4..6acb97b 100644 --- a/docs/data/it-trimfirst.md +++ b/docs/data/it-trimfirst.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func TrimFirst[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I" +playUrl: https://go.dev/play/p/4D4Ke5C5MwH variantHelpers: - it#string#trim - it#string#trimlast diff --git a/docs/data/it-trimlast.md b/docs/data/it-trimlast.md index 04f8e1d..9ba548a 100644 --- a/docs/data/it-trimlast.md +++ b/docs/data/it-trimlast.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func TrimLast[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I" +playUrl: https://go.dev/play/p/GQLhnaeW0gd variantHelpers: - it#string#trim - it#string#trimfirst diff --git a/docs/data/it-trimprefix.md b/docs/data/it-trimprefix.md index 473b325..9c1a743 100644 --- a/docs/data/it-trimprefix.md +++ b/docs/data/it-trimprefix.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func TrimPrefix[T comparable, I ~func(func(T) bool)](collection I, prefix []T) I" +playUrl: https://go.dev/play/p/Pce4zSPnThY variantHelpers: [] similarHelpers: - core#string#trimprefix diff --git a/docs/data/it-trimsuffix.md b/docs/data/it-trimsuffix.md index 72e17c0..79a962d 100644 --- a/docs/data/it-trimsuffix.md +++ b/docs/data/it-trimsuffix.md @@ -6,6 +6,7 @@ category: it subCategory: string signatures: - "func TrimSuffix[T comparable, I ~func(func(T) bool)](collection I, suffix []T) I" +playUrl: https://go.dev/play/p/s9nwy9helEi variantHelpers: [] similarHelpers: - core#string#trimsuffix diff --git a/docs/data/it-uniq.md b/docs/data/it-uniq.md index 869cf09..5754f08 100644 --- a/docs/data/it-uniq.md +++ b/docs/data/it-uniq.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func Uniq[T comparable, I ~func(func(T) bool)](collection I) I" -playUrl: "https://go.dev/play/p/0RlEI4-zq" +playUrl: https://go.dev/play/p/D-SenTW-ipj variantHelpers: - it#sequence#uniq similarHelpers: diff --git a/docs/data/it-uniqby.md b/docs/data/it-uniqby.md index 65d9508..2100751 100644 --- a/docs/data/it-uniqby.md +++ b/docs/data/it-uniqby.md @@ -6,7 +6,7 @@ category: it subCategory: sequence signatures: - "func UniqBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I" -playUrl: +playUrl: https://go.dev/play/p/HKrt3AvwMTR variantHelpers: - it#slice#uniq similarHelpers: diff --git a/docs/data/it-uniqvalues.md b/docs/data/it-uniqvalues.md index b6261d0..9058f20 100644 --- a/docs/data/it-uniqvalues.md +++ b/docs/data/it-uniqvalues.md @@ -6,7 +6,7 @@ category: it subCategory: map signatures: - "func UniqValues[K, V comparable](in ...map[K]V) iter.Seq[V]" -playUrl: "https://go.dev/play/p/M7qV2xP4yG8" +playUrl: https://go.dev/play/p/QQv4zGrk-fF variantHelpers: - it#map#uniqvalues similarHelpers: diff --git a/docs/data/it-values.md b/docs/data/it-values.md index f91d047..81ec448 100644 --- a/docs/data/it-values.md +++ b/docs/data/it-values.md @@ -6,7 +6,7 @@ category: it subCategory: map signatures: - "func Values[K comparable, V any](in ...map[K]V) iter.Seq[V]" -playUrl: "https://go.dev/play/p/L9KcJ3h8E4f" +playUrl: https://go.dev/play/p/-WehUfGtC6C variantHelpers: - it#map#values similarHelpers: diff --git a/docs/data/it-window.md b/docs/data/it-window.md index d55d8d6..eddb847 100644 --- a/docs/data/it-window.md +++ b/docs/data/it-window.md @@ -6,6 +6,7 @@ category: it subCategory: sequence signatures: - "func Window[T any](collection iter.Seq[T], size int) iter.Seq[[]T]" +playUrl: https://go.dev/play/p/_1BzQYtKBhi variantHelpers: - it#sequence#window similarHelpers: diff --git a/docs/data/it-without.md b/docs/data/it-without.md index 7ca9d0d..129c6ac 100644 --- a/docs/data/it-without.md +++ b/docs/data/it-without.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func Without[T comparable, I ~func(func(T) bool)](collection I, exclude ...T) I" -playUrl: "https://go.dev/play/p/eAOoUsQnrZf" +playUrl: "https://go.dev/play/p/LbN55AVBZ7h" variantHelpers: - it#intersect#without similarHelpers: diff --git a/docs/data/it-withoutby.md b/docs/data/it-withoutby.md index 664ea8f..6496527 100644 --- a/docs/data/it-withoutby.md +++ b/docs/data/it-withoutby.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func WithoutBy[T any, K comparable, I ~func(func(T) bool)](collection I, transform func(item T) K, exclude ...K) I" -playUrl: "https://go.dev/play/p/6XrQKOk-vw" +playUrl: "https://go.dev/play/p/Hm734hnLnLI" variantHelpers: - it#intersect#withoutby similarHelpers: diff --git a/docs/data/it-withoutnth.md b/docs/data/it-withoutnth.md index 64906c1..f828906 100644 --- a/docs/data/it-withoutnth.md +++ b/docs/data/it-withoutnth.md @@ -6,7 +6,7 @@ category: it subCategory: intersect signatures: - "func WithoutNth[T comparable, I ~func(func(T) bool)](collection I, nths ...int) I" -playUrl: "https://go.dev/play/p/7XrQKOk-vw" +playUrl: "https://go.dev/play/p/KGE7Lpsk18P" variantHelpers: - it#intersect#withoutnth similarHelpers: diff --git a/docs/data/it-zipbyx.md b/docs/data/it-zipbyx.md index d492d4a..b1970aa 100644 --- a/docs/data/it-zipbyx.md +++ b/docs/data/it-zipbyx.md @@ -13,7 +13,7 @@ signatures: - "func ZipBy7[T1, T2, T3, T4, T5, T6, T7, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], transform func(T1, T2, T3, T4, T5, T6, T7) R) iter.Seq[R]" - "func ZipBy8[T1, T2, T3, T4, T5, T6, T7, T8, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], seq8 iter.Seq[T8], transform func(T1, T2, T3, T4, T5, T6, T7, T8) R) iter.Seq[R]" - "func ZipBy9[T1, T2, T3, T4, T5, T6, T7, T8, T9, R any](seq1 iter.Seq[T1], seq2 iter.Seq[T2], seq3 iter.Seq[T3], seq4 iter.Seq[T4], seq5 iter.Seq[T5], seq6 iter.Seq[T6], seq7 iter.Seq[T7], seq8 iter.Seq[T8], seq9 iter.Seq[T9], transform func(T1, T2, T3, T4, T5, T6, T7, T8, T9) R) iter.Seq[R]" -playUrl: "https://go.dev/play/p/2TnGK6-zs" +playUrl: https://go.dev/play/p/y03uqMEAi1E variantHelpers: - it#tuple#zipbyx similarHelpers: diff --git a/docs/data/parallel-groupby.md b/docs/data/parallel-groupby.md index 333d6ed..9701336 100644 --- a/docs/data/parallel-groupby.md +++ b/docs/data/parallel-groupby.md @@ -4,7 +4,7 @@ slug: groupby sourceRef: parallel/slice.go#L73 category: parallel subCategory: slice -playUrl: "" +playUrl: "https://go.dev/play/p/EkyvA0gw4dj" similarHelpers: - core#slice#groupby - core#slice#groupbymap diff --git a/docs/data/parallel-partitionby.md b/docs/data/parallel-partitionby.md index b2ac9ef..1513f49 100644 --- a/docs/data/parallel-partitionby.md +++ b/docs/data/parallel-partitionby.md @@ -4,7 +4,7 @@ slug: partitionby sourceRef: parallel/slice.go#L92 category: parallel subCategory: slice -playUrl: "" +playUrl: "https://go.dev/play/p/GwBQdMgx2nC" similarHelpers: - core#slice#partitionby - parallel#slice#groupby diff --git a/docs/data/parallel-times.md b/docs/data/parallel-times.md index 244f381..8782257 100644 --- a/docs/data/parallel-times.md +++ b/docs/data/parallel-times.md @@ -4,7 +4,7 @@ slug: times sourceRef: parallel/slice.go#L49 category: parallel subCategory: slice -playUrl: "" +playUrl: https://go.dev/play/p/ZNnWNcJ4Au- similarHelpers: - core#slice#times position: 20 diff --git a/find.go b/find.go index f5be852..0ce2f6c 100644 --- a/find.go +++ b/find.go @@ -84,6 +84,7 @@ func Find[T any](collection []T, predicate func(item T) bool) (T, bool) { // Returns the element and nil error if the element is found. // Returns zero value and nil error if the element is not found. // If the predicate returns an error, iteration stops immediately and returns zero value and the error. +// Play: https://go.dev/play/p/XK-qtpQWXJ9 func FindErr[T any](collection []T, predicate func(item T) (bool, error)) (T, error) { for i := range collection { matches, err := predicate(collection[i]) @@ -116,7 +117,7 @@ func FindIndexOf[T any](collection []T, predicate func(item T) bool) (T, int, bo // FindLastIndexOf searches for the last element in a slice based on a predicate and returns the index and true. // Returns -1 and false if the element is not found. -// Play: https://go.dev/play/p/dPiMRtJ6cUx +// Play: https://go.dev/play/p/2VhPMiQvX-D func FindLastIndexOf[T any](collection []T, predicate func(item T) bool) (T, int, bool) { length := len(collection) @@ -168,6 +169,7 @@ func FindKeyBy[K comparable, V any](object map[K]V, predicate func(key K, value // FindUniques returns a slice with all the elements that appear in the collection only once. // The order of result values is determined by the order they occur in the collection. +// Play: https://go.dev/play/p/NV5vMK_2Z_n func FindUniques[T comparable, Slice ~[]T](collection Slice) Slice { isDupl := make(map[T]bool, len(collection)) @@ -198,6 +200,7 @@ func FindUniques[T comparable, Slice ~[]T](collection Slice) Slice { // FindUniquesBy returns a slice with all the elements that appear in the collection only once. // The order of result values is determined by the order they occur in the slice. It accepts `iteratee` which is // invoked for each element in the slice to generate the criterion by which uniqueness is computed. +// Play: https://go.dev/play/p/2vmxCs4kW_m func FindUniquesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice { isDupl := make(map[U]bool, len(collection)) @@ -231,6 +234,7 @@ func FindUniquesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee f // FindDuplicates returns a slice with the first occurrence of each duplicated element in the collection. // The order of result values is determined by the order they occur in the collection. +// Play: https://go.dev/play/p/muFgL_XBwoP func FindDuplicates[T comparable, Slice ~[]T](collection Slice) Slice { isDupl := make(map[T]bool, len(collection)) @@ -262,6 +266,7 @@ func FindDuplicates[T comparable, Slice ~[]T](collection Slice) Slice { // FindDuplicatesBy returns a slice with the first occurrence of each duplicated element in the collection. // The order of result values is determined by the order they occur in the slice. It accepts `iteratee` which is // invoked for each element in the slice to generate the criterion by which uniqueness is computed. +// Play: https://go.dev/play/p/LKdYdNHuGJG func FindDuplicatesBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) Slice { isDupl := make(map[U]bool, len(collection)) @@ -298,6 +303,7 @@ func FindDuplicatesBy[T any, U comparable, Slice ~[]T](collection Slice, iterate // The order of result values is determined by the order they occur in the slice. It accepts `iteratee` which is // invoked for each element in the slice to generate the criterion by which uniqueness is computed. // If the iteratee returns an error, iteration stops immediately and the error is returned with a nil slice. +// Play: https://go.dev/play/p/HiVILQqdFP0 func FindDuplicatesByErr[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) (U, error)) (Slice, error) { isDupl := make(map[U]bool, len(collection)) @@ -342,7 +348,7 @@ func FindDuplicatesByErr[T any, U comparable, Slice ~[]T](collection Slice, iter // Min search the minimum value of a collection. // Returns zero value when the collection is empty. -// Play: https://go.dev/play/p/r6e-Z8JozS8 +// Play: https://go.dev/play/p/fJFLwpY8eMN func Min[T constraints.Ordered](collection []T) T { var mIn T @@ -365,6 +371,7 @@ func Min[T constraints.Ordered](collection []T) T { // MinIndex search the minimum value of a collection and the index of the minimum value. // Returns (zero value, -1) when the collection is empty. +// Play: https://go.dev/play/p/RxAidik4p50 func MinIndex[T constraints.Ordered](collection []T) (T, int) { var ( mIn T @@ -392,6 +399,7 @@ func MinIndex[T constraints.Ordered](collection []T) (T, int) { // MinBy search the minimum value of a collection using the given comparison function. // If several values of the collection are equal to the smallest value, returns the first such value. // Returns zero value when the collection is empty. +// Play: https://go.dev/play/p/-B1PsrHVnfx func MinBy[T any](collection []T, less func(a, b T) bool) T { var mIn T @@ -416,6 +424,7 @@ func MinBy[T any](collection []T, less func(a, b T) bool) T { // If several values of the collection are equal to the smallest value, returns the first such value. // Returns zero value and nil error when the collection is empty. // If the comparison function returns an error, iteration stops and the error is returned. +// Play: https://go.dev/play/p/nvDYGS8q895 func MinByErr[T any](collection []T, less func(a, b T) (bool, error)) (T, error) { var mIn T @@ -444,6 +453,7 @@ func MinByErr[T any](collection []T, less func(a, b T) (bool, error)) (T, error) // MinIndexBy search the minimum value of a collection using the given comparison function and the index of the minimum value. // If several values of the collection are equal to the smallest value, returns the first such value. // Returns (zero value, -1) when the collection is empty. +// Play: https://go.dev/play/p/zwwPRqWhnUY func MinIndexBy[T any](collection []T, less func(a, b T) bool) (T, int) { var ( mIn T @@ -472,6 +482,7 @@ func MinIndexBy[T any](collection []T, less func(a, b T) bool) (T, int) { // If several values of the collection are equal to the smallest value, returns the first such value. // Returns (zero value, -1) when the collection is empty. // Comparison function can return an error to stop iteration immediately. +// Play: https://go.dev/play/p/MUqi_NvTKM1 func MinIndexByErr[T any](collection []T, less func(a, b T) (bool, error)) (T, int, error) { var ( mIn T @@ -504,6 +515,7 @@ func MinIndexByErr[T any](collection []T, less func(a, b T) (bool, error)) (T, i // Earliest search the minimum time.Time of a collection. // Returns zero value when the collection is empty. +// Play: https://go.dev/play/p/pRyy0c6hsBs func Earliest(times ...time.Time) time.Time { var mIn time.Time @@ -526,6 +538,7 @@ func Earliest(times ...time.Time) time.Time { // EarliestBy search the minimum time.Time of a collection using the given iteratee function. // Returns zero value when the collection is empty. +// Play: https://go.dev/play/p/0XvCF6vuLXC func EarliestBy[T any](collection []T, iteratee func(item T) time.Time) T { var earliest T @@ -551,6 +564,7 @@ func EarliestBy[T any](collection []T, iteratee func(item T) time.Time) T { // EarliestByErr search the minimum time.Time of a collection using the given iteratee function. // Returns zero value and nil error when the collection is empty. // If the iteratee returns an error, iteration stops and the error is returned. +// Play: https://go.dev/play/p/zJUBUj7ANvq func EarliestByErr[T any](collection []T, iteratee func(item T) (time.Time, error)) (T, error) { var earliest T @@ -581,7 +595,7 @@ func EarliestByErr[T any](collection []T, iteratee func(item T) (time.Time, erro // Max searches the maximum value of a collection. // Returns zero value when the collection is empty. -// Play: https://go.dev/play/p/r6e-Z8JozS8 +// Play: https://go.dev/play/p/wYvG8gRRFw- func Max[T constraints.Ordered](collection []T) T { var mAx T @@ -604,6 +618,7 @@ func Max[T constraints.Ordered](collection []T) T { // MaxIndex searches the maximum value of a collection and the index of the maximum value. // Returns (zero value, -1) when the collection is empty. +// Play: https://go.dev/play/p/RFkB4Mzb1qt func MaxIndex[T constraints.Ordered](collection []T) (T, int) { var ( mAx T @@ -635,7 +650,7 @@ func MaxIndex[T constraints.Ordered](collection []T) (T, int) { // Note: the comparison function is inconsistent with most languages, since we use the opposite of the usual convention. // See https://github.com/samber/lo/issues/129 // -// Play: https://go.dev/play/p/JW1qu-ECwF7 +// Play: https://go.dev/play/p/PJCc-ThrwX1 func MaxBy[T any](collection []T, greater func(a, b T) bool) T { var mAx T @@ -663,6 +678,8 @@ func MaxBy[T any](collection []T, greater func(a, b T) bool) T { // // Note: the comparison function is inconsistent with most languages, since we use the opposite of the usual convention. // See https://github.com/samber/lo/issues/129 +// +// Play: https://go.dev/play/p/s-63-6_9zqM func MaxByErr[T any](collection []T, greater func(a, b T) (bool, error)) (T, error) { var mAx T @@ -694,7 +711,7 @@ func MaxByErr[T any](collection []T, greater func(a, b T) (bool, error)) (T, err // Note: the comparison function is inconsistent with most languages, since we use the opposite of the usual convention. // See https://github.com/samber/lo/issues/129 // -// Play: https://go.dev/play/p/uaUszc-c9QK +// Play: https://go.dev/play/p/5yd4W7pe2QJ func MaxIndexBy[T any](collection []T, greater func(a, b T) bool) (T, int) { var ( mAx T @@ -757,6 +774,7 @@ func MaxIndexByErr[T any](collection []T, greater func(a, b T) (bool, error)) (T // Latest search the maximum time.Time of a collection. // Returns zero value when the collection is empty. +// Play: https://go.dev/play/p/dBfdf5s8s-Y func Latest(times ...time.Time) time.Time { var mAx time.Time @@ -779,6 +797,7 @@ func Latest(times ...time.Time) time.Time { // LatestBy search the maximum time.Time of a collection using the given iteratee function. // Returns zero value when the collection is empty. +// Play: https://go.dev/play/p/p1HA8XumaMU func LatestBy[T any](collection []T, iteratee func(item T) time.Time) T { var latest T @@ -804,6 +823,7 @@ func LatestBy[T any](collection []T, iteratee func(item T) time.Time) T { // LatestByErr search the maximum time.Time of a collection using the given iteratee function. // Returns zero value and nil error when the collection is empty. // If the iteratee returns an error, iteration stops and the error is returned. +// Play: https://go.dev/play/p/WpBUptwnxuG func LatestByErr[T any](collection []T, iteratee func(item T) (time.Time, error)) (T, error) { var latest T @@ -833,7 +853,7 @@ func LatestByErr[T any](collection []T, iteratee func(item T) (time.Time, error) } // First returns the first element of a collection and check for availability of the first element. -// Play: https://go.dev/play/p/ul45Z0y2EFO +// Play: https://go.dev/play/p/94lu5X6_cbf func First[T any](collection []T) (T, bool) { length := len(collection) @@ -846,14 +866,14 @@ func First[T any](collection []T) (T, bool) { } // FirstOrEmpty returns the first element of a collection or zero value if empty. -// Play: https://go.dev/play/p/ul45Z0y2EFO +// Play: https://go.dev/play/p/i200n9wgrDA func FirstOrEmpty[T any](collection []T) T { i, _ := First(collection) return i } // FirstOr returns the first element of a collection or the fallback value if empty. -// Play: https://go.dev/play/p/ul45Z0y2EFO +// Play: https://go.dev/play/p/x9CxQyRFXeZ func FirstOr[T any](collection []T, fallback T) T { i, ok := First(collection) if !ok { @@ -896,7 +916,7 @@ func LastOr[T any](collection []T, fallback T) T { // Nth returns the element at index `nth` of collection. If `nth` is negative, the nth element // from the end is returned. An error is returned when nth is out of slice bounds. -// Play: https://go.dev/play/p/sHoh88KWt6B +// Play: https://go.dev/play/p/mNFI9-kIZZ5 func Nth[T any, N constraints.Integer](collection []T, nth N) (T, error) { value, ok := sliceNth(collection, nth) @@ -919,7 +939,7 @@ func sliceNth[T any, N constraints.Integer](collection []T, nth N) (T, bool) { // NthOr returns the element at index `nth` of collection. // If `nth` is negative, it returns the nth element from the end. // If `nth` is out of slice bounds, it returns the fallback value instead of an error. -// Play: https://go.dev/play/p/sHoh88KWt6B +// Play: https://go.dev/play/p/njKcNhBBVsF func NthOr[T any, N constraints.Integer](collection []T, nth N, fallback T) T { value, ok := sliceNth(collection, nth) if !ok { @@ -958,13 +978,13 @@ func SampleBy[T any](collection []T, randomIntGenerator randomIntGenerator) T { } // Samples returns N random unique items from collection. -// Play: https://go.dev/play/p/vCcSJbh5s6l +// Play: https://go.dev/play/p/QYRD8aufD0C func Samples[T any, Slice ~[]T](collection Slice, count int) Slice { return SamplesBy(collection, count, xrand.IntN) } // SamplesBy returns N random unique items from collection, using randomIntGenerator as the random index generator. -// Play: https://go.dev/play/p/HDmKmMgq0XN +// Play: https://go.dev/play/p/Dy9bGDhD_Gw func SamplesBy[T any, Slice ~[]T](collection Slice, count int, randomIntGenerator randomIntGenerator) Slice { if count <= 0 { return Slice{} diff --git a/intersect.go b/intersect.go index 46ffad8..4273c0c 100644 --- a/intersect.go +++ b/intersect.go @@ -158,6 +158,7 @@ func Intersect[T comparable, Slice ~[]T](lists ...Slice) Slice { } // IntersectBy returns the intersection between two collections using a custom key selector function. +// Play: https://go.dev/play/p/uWF8y2-zmtf func IntersectBy[T any, K comparable, Slice ~[]T](transform func(T) K, lists ...Slice) Slice { if len(lists) == 0 { return Slice{} @@ -230,7 +231,7 @@ func Difference[T comparable, Slice ~[]T](list1, list2 Slice) (Slice, Slice) { // Union returns all distinct elements from given collections. // result returns will not change the order of elements relatively. -// Play: https://go.dev/play/p/DI9RVEB_qMK +// Play: https://go.dev/play/p/-hsqZNTH0ej func Union[T comparable, Slice ~[]T](lists ...Slice) Slice { var capLen int @@ -254,7 +255,7 @@ func Union[T comparable, Slice ~[]T](lists ...Slice) Slice { } // Without returns a slice excluding all given values. -// Play: https://go.dev/play/p/5j30Ux8TaD0 +// Play: https://go.dev/play/p/PcAVtYJsEsS func Without[T comparable, Slice ~[]T](collection Slice, exclude ...T) Slice { excludeMap := Keyify(exclude) @@ -303,6 +304,7 @@ func WithoutByErr[T any, K comparable, Slice ~[]T](collection Slice, iteratee fu // WithoutEmpty returns a slice excluding zero values. // // Deprecated: Use lo.Compact instead. +// Play: https://go.dev/play/p/iZvYJWuniJm func WithoutEmpty[T comparable, Slice ~[]T](collection Slice) Slice { return Compact(collection) } diff --git a/it/find.go b/it/find.go index 389aaaa..ddc6850 100644 --- a/it/find.go +++ b/it/find.go @@ -31,7 +31,7 @@ func IndexOf[T comparable](collection iter.Seq[T], element T) int { // LastIndexOf returns the index at which the last occurrence of a value is found in a sequence or -1 // if the value cannot be found. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/2PaIZ3gc-n +// Play: https://go.dev/play/p/QPATR3VC5wT func LastIndexOf[T comparable](collection iter.Seq[T], element T) int { index := -1 var i int @@ -47,7 +47,7 @@ func LastIndexOf[T comparable](collection iter.Seq[T], element T) int { // HasPrefix returns true if the collection has the prefix. // Will iterate at most the size of prefix. -// Play: https://go.dev/play/p/3QbJK4hd-o +// Play: https://go.dev/play/p/Fyj6uq-G5IH func HasPrefix[T comparable](collection iter.Seq[T], prefix ...T) bool { if len(prefix) == 0 { return true @@ -70,7 +70,7 @@ func HasPrefix[T comparable](collection iter.Seq[T], prefix ...T) bool { // HasSuffix returns true if the collection has the suffix. // Will iterate through the entire sequence and allocate a slice the size of suffix. -// Play: https://go.dev/play/p/4RcKL5ie-p +// Play: https://go.dev/play/p/r6bF9Rmq5S0 func HasSuffix[T comparable](collection iter.Seq[T], suffix ...T) bool { if len(suffix) == 0 { return true @@ -99,7 +99,7 @@ func HasSuffix[T comparable](collection iter.Seq[T], suffix ...T) bool { // Find searches for an element in a sequence based on a predicate. Returns element and true if element was found. // Will iterate through the entire sequence if predicate never returns true. -// Play: https://go.dev/play/p/5SdLM6jf-q +// Play: https://go.dev/play/p/4w28pF_l58a func Find[T any](collection iter.Seq[T], predicate func(item T) bool) (T, bool) { for item := range collection { if predicate(item) { @@ -113,7 +113,7 @@ func Find[T any](collection iter.Seq[T], predicate func(item T) bool) (T, bool) // FindIndexOf searches for an element in a sequence based on a predicate and returns the index and true. // Returns -1 and false if the element is not found. // Will iterate through the entire sequence if predicate never returns true. -// Play: https://go.dev/play/p/6TeNM7kg-r +// Play: https://go.dev/play/p/ihchBAEkhXO func FindIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) (T, int, bool) { var i int for item := range collection { @@ -129,7 +129,7 @@ func FindIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) (T, // FindLastIndexOf searches for the last element in a sequence based on a predicate and returns the index and true. // Returns -1 and false if the element is not found. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/7UfON8lh-s +// Play: https://go.dev/play/p/ezz6hXaC4Md func FindLastIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) (T, int, bool) { var result T index := -1 @@ -150,7 +150,7 @@ func FindLastIndexOf[T any](collection iter.Seq[T], predicate func(item T) bool) // FindOrElse searches for an element in a sequence based on a predicate. Returns the element if found or a given fallback value otherwise. // Will iterate through the entire sequence if predicate never returns true. -// Play: https://go.dev/play/p/8VgPO9mi-t +// Play: https://go.dev/play/p/1harvaiGMfI func FindOrElse[T any](collection iter.Seq[T], fallback T, predicate func(item T) bool) T { if result, ok := Find(collection, predicate); ok { return result @@ -163,7 +163,7 @@ func FindOrElse[T any](collection iter.Seq[T], fallback T, predicate func(item T // The order of result values is determined by the order they occur in the collection. // Will iterate through the entire sequence before yielding and allocate a map large enough to hold all distinct elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/9WhQPJnj-u +// Play: https://go.dev/play/p/O8dwXEbT56F func FindUniques[T comparable, I ~func(func(T) bool)](collection I) I { return FindUniquesBy(collection, func(item T) T { return item }) } @@ -173,7 +173,7 @@ func FindUniques[T comparable, I ~func(func(T) bool)](collection I) I { // invoked for each element in the sequence to generate the criterion by which uniqueness is computed. // Will iterate through the entire sequence before yielding and allocate a map large enough to hold all distinct transformed elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/0XrQKOk-vw +// Play: https://go.dev/play/p/TiwGIzeDuML func FindUniquesBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I { return func(yield func(T) bool) { isDupl := make(map[U]bool) @@ -201,7 +201,7 @@ func FindUniquesBy[T any, U comparable, I ~func(func(T) bool)](collection I, tra // The order of result values is determined by the order duplicates occur in the collection. // Will allocate a map large enough to hold all distinct elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/1YsRLPl-wx +// Play: https://go.dev/play/p/dw-VLQXKijT func FindDuplicates[T comparable, I ~func(func(T) bool)](collection I) I { return FindDuplicatesBy(collection, func(item T) T { return item }) } @@ -211,7 +211,7 @@ func FindDuplicates[T comparable, I ~func(func(T) bool)](collection I) I { // invoked for each element in the sequence to generate the criterion by which uniqueness is computed. // Will allocate a map large enough to hold all distinct transformed elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/2ZtSMQm-xy +// Play: https://go.dev/play/p/tm1tZdC93OH func FindDuplicatesBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I { return func(yield func(T) bool) { isDupl := make(map[U]lo.Tuple2[T, bool]) @@ -234,7 +234,7 @@ func FindDuplicatesBy[T any, U comparable, I ~func(func(T) bool)](collection I, // Min search the minimum value of a collection. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/3AuTNRn-yz +// Play: https://go.dev/play/p/0VihyYEaM-M func Min[T constraints.Ordered](collection iter.Seq[T]) T { return MinBy(collection, func(a, b T) bool { return a < b }) } @@ -242,7 +242,7 @@ func Min[T constraints.Ordered](collection iter.Seq[T]) T { // MinIndex search the minimum value of a collection and the index of the minimum value. // Returns (zero value, -1) when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/4BvOSo-yza +// Play: https://go.dev/play/p/70ncPxECj6l func MinIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int) { return MinIndexBy(collection, func(a, b T) bool { return a < b }) } @@ -251,7 +251,7 @@ func MinIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int) { // If several values of the collection are equal to the smallest value, returns the first such value. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/5CwPTPz-zb +// Play: https://go.dev/play/p/J5koo8khN-g func MinBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T { first := true var mIn T @@ -272,7 +272,7 @@ func MinBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T { // If several values of the collection are equal to the smallest value, returns the first such value. // Returns (zero value, -1) when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/6DxQUQ0-zc +// Play: https://go.dev/play/p/blldzWJpqVa func MinIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, int) { var mIn T index := -1 @@ -292,7 +292,7 @@ func MinIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, // Earliest search the minimum time.Time of a collection. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/7EyYRV1-zd +// Play: https://go.dev/play/p/fI6_S10H7Py func Earliest(times iter.Seq[time.Time]) time.Time { return MinBy(times, func(a, b time.Time) bool { return a.Before(b) }) } @@ -300,7 +300,7 @@ func Earliest(times iter.Seq[time.Time]) time.Time { // EarliestBy search the minimum time.Time of a collection using the given transform function. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/8FzSW2-ze +// Play: https://go.dev/play/p/y_Pf3Jmw-B4 func EarliestBy[T any](collection iter.Seq[T], transform func(item T) time.Time) T { return MinBy(collection, func(a, b T) bool { return transform(a).Before(transform(b)) }) } @@ -308,7 +308,7 @@ func EarliestBy[T any](collection iter.Seq[T], transform func(item T) time.Time) // Max searches the maximum value of a collection. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/9GaTX3-zf +// Play: https://go.dev/play/p/C2ZtW2bsBZ6 func Max[T constraints.Ordered](collection iter.Seq[T]) T { return MaxBy(collection, func(a, b T) bool { return a > b }) } @@ -316,7 +316,7 @@ func Max[T constraints.Ordered](collection iter.Seq[T]) T { // MaxIndex searches the maximum value of a collection and the index of the maximum value. // Returns (zero value, -1) when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/0HbUY4-zg +// Play: https://go.dev/play/p/zeu2wUvhl5e func MaxIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int) { return MaxIndexBy(collection, func(a, b T) bool { return a > b }) } @@ -325,7 +325,7 @@ func MaxIndex[T constraints.Ordered](collection iter.Seq[T]) (T, int) { // If several values of the collection are equal to the greatest value, returns the first such value. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/1IcVZ5-zh +// Play: https://go.dev/play/p/yBhXFJb5oxC func MaxBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T { first := true var mAx T @@ -346,7 +346,7 @@ func MaxBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) T { // If several values of the collection are equal to the greatest value, returns the first such value. // Returns (zero value, -1) when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/2JdWA6-zi +// Play: https://go.dev/play/p/MXyE6BTILjx func MaxIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, int) { var mAx T index := -1 @@ -366,7 +366,7 @@ func MaxIndexBy[T any](collection iter.Seq[T], comparison func(a, b T) bool) (T, // Latest search the maximum time.Time of a collection. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/3KeXB7-zj +// Play: https://go.dev/play/p/r5Yq6ATSHoH func Latest(times iter.Seq[time.Time]) time.Time { return MaxBy(times, func(a, b time.Time) bool { return a.After(b) }) } @@ -374,14 +374,14 @@ func Latest(times iter.Seq[time.Time]) time.Time { // LatestBy search the maximum time.Time of a collection using the given transform function. // Returns zero value when the collection is empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/4LfYC8-zk +// Play: https://go.dev/play/p/o_daRzHrDUU func LatestBy[T any](collection iter.Seq[T], transform func(item T) time.Time) T { return MaxBy(collection, func(a, b T) bool { return transform(a).After(transform(b)) }) } // First returns the first element of a collection and check for availability of the first element. // Will iterate at most once. -// Play: https://go.dev/play/p/5MgZD9-zl +// Play: https://go.dev/play/p/EhNyrc8jPfY func First[T any](collection iter.Seq[T]) (T, bool) { for item := range collection { return item, true @@ -392,7 +392,7 @@ func First[T any](collection iter.Seq[T]) (T, bool) { // FirstOrEmpty returns the first element of a collection or zero value if empty. // Will iterate at most once. -// Play: https://go.dev/play/p/6NhAE0-zm +// Play: https://go.dev/play/p/NTUTgPCfevx func FirstOrEmpty[T any](collection iter.Seq[T]) T { i, _ := First(collection) return i @@ -400,7 +400,7 @@ func FirstOrEmpty[T any](collection iter.Seq[T]) T { // FirstOr returns the first element of a collection or the fallback value if empty. // Will iterate at most once. -// Play: https://go.dev/play/p/7OiBF1-zn +// Play: https://go.dev/play/p/wGFXI5NHkE2 func FirstOr[T any](collection iter.Seq[T], fallback T) T { if i, ok := First(collection); ok { return i @@ -411,7 +411,7 @@ func FirstOr[T any](collection iter.Seq[T], fallback T) T { // Last returns the last element of a collection or error if empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/8PjCG2-zo +// Play: https://go.dev/play/p/eGZV-sSmn_Q func Last[T any](collection iter.Seq[T]) (T, bool) { var t T var ok bool @@ -425,7 +425,7 @@ func Last[T any](collection iter.Seq[T]) (T, bool) { // LastOrEmpty returns the last element of a collection or zero value if empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/9QkDH3-zp +// Play: https://go.dev/play/p/teODFK4YqM4 func LastOrEmpty[T any](collection iter.Seq[T]) T { i, _ := Last(collection) return i @@ -433,7 +433,7 @@ func LastOrEmpty[T any](collection iter.Seq[T]) T { // LastOr returns the last element of a collection or the fallback value if empty. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/0RlEI4-zq +// Play: https://go.dev/play/p/HNubjW2Mrxs func LastOr[T any](collection iter.Seq[T], fallback T) T { if i, ok := Last(collection); ok { return i @@ -444,7 +444,7 @@ func LastOr[T any](collection iter.Seq[T], fallback T) T { // Nth returns the element at index `nth` of collection. An error is returned when nth is out of bounds. // Will iterate n times through the sequence. -// Play: https://go.dev/play/p/1SmFJ5-zr +// Play: https://go.dev/play/p/FqgCobsKqva func Nth[T any, N constraints.Integer](collection iter.Seq[T], nth N) (T, error) { value, ok := seqNth(collection, nth) @@ -468,7 +468,7 @@ func seqNth[T any, N constraints.Integer](collection iter.Seq[T], nth N) (T, boo // NthOr returns the element at index `nth` of collection. // If `nth` is out of bounds, it returns the fallback value instead of an error. // Will iterate n times through the sequence. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/MNweuhpy4Ym func NthOr[T any, N constraints.Integer](collection iter.Seq[T], nth N, fallback T) T { value, ok := seqNth(collection, nth) if !ok { @@ -480,7 +480,7 @@ func NthOr[T any, N constraints.Integer](collection iter.Seq[T], nth N, fallback // NthOrEmpty returns the element at index `nth` of collection. // If `nth` is out of bounds, it returns the zero value (empty value) for that type. // Will iterate n times through the sequence. -// Play: https://go.dev/play/p/3UoHL7-zt +// Play: https://go.dev/play/p/pC0Zhu3EUhe func NthOrEmpty[T any, N constraints.Integer](collection iter.Seq[T], nth N) T { value, _ := seqNth(collection, nth) return value @@ -489,7 +489,7 @@ func NthOrEmpty[T any, N constraints.Integer](collection iter.Seq[T], nth N) T { // Sample returns a random item from collection. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/4VpIM8-zu +// Play: https://go.dev/play/p/YDJVX0UXYDi func Sample[T any](collection iter.Seq[T]) T { return SampleBy(collection, xrand.IntN) } @@ -497,7 +497,7 @@ func Sample[T any](collection iter.Seq[T]) T { // SampleBy returns a random item from collection, using randomIntGenerator as the random index generator. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/5WqJN9-zv +// Play: https://go.dev/play/p/QQooySxORib func SampleBy[T any](collection iter.Seq[T], randomIntGenerator func(int) int) T { slice := slices.Collect(collection) return lo.SampleBy(slice, randomIntGenerator) @@ -506,7 +506,7 @@ func SampleBy[T any](collection iter.Seq[T], randomIntGenerator func(int) int) T // Samples returns N random unique items from collection. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/6XrKO0-zw +// Play: https://go.dev/play/p/GUTFx9LQ8pP func Samples[T any, I ~func(func(T) bool)](collection I, count int) I { return SamplesBy(collection, count, xrand.IntN) } @@ -514,7 +514,7 @@ func Samples[T any, I ~func(func(T) bool)](collection I, count int) I { // SamplesBy returns N random unique items from collection, using randomIntGenerator as the random index generator. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/7YsLP1-zx +// Play: https://go.dev/play/p/fX2FEtixrVG func SamplesBy[T any, I ~func(func(T) bool)](collection I, count int, randomIntGenerator func(int) int) I { slice := slices.Collect(iter.Seq[T](collection)) seq := lo.SamplesBy(slice, count, randomIntGenerator) diff --git a/it/intersect.go b/it/intersect.go index 088ec23..603b084 100644 --- a/it/intersect.go +++ b/it/intersect.go @@ -91,7 +91,7 @@ func SomeBy[T any](collection iter.Seq[T], predicate func(item T) bool) bool { // None returns true if no element of a subset is contained in a collection or if the subset is empty. // Will iterate through the entire sequence if subset elements never match. -// Play: https://go.dev/play/p/KmX-fXictQl +// Play: https://go.dev/play/p/L7mm5S4a8Yo func None[T comparable](collection iter.Seq[T], subset ...T) bool { if len(subset) == 0 { return true @@ -165,6 +165,7 @@ func Intersect[T comparable, I ~func(func(T) bool)](lists ...I) I { // custom key selector function. // Will allocate a map large enough to hold all distinct elements. // Long heterogeneous input sequences can cause excessive memory usage. +// Play: https://go.dev/play/p/X2nEvHC-lE2 func IntersectBy[T any, K comparable, I ~func(func(T) bool)](transform func(T) K, lists ...I) I { if len(lists) == 0 { return I(Empty[T]()) @@ -232,7 +233,7 @@ func Union[T comparable, I ~func(func(T) bool)](lists ...I) I { // Without returns a sequence excluding all given values. // Will allocate a map large enough to hold all distinct excludes. -// Play: https://go.dev/play/p/eAOoUsQnrZf +// Play: https://go.dev/play/p/LbN55AVBZ7h func Without[T comparable, I ~func(func(T) bool)](collection I, exclude ...T) I { return WithoutBy(collection, func(item T) T { return item }, exclude...) } @@ -240,6 +241,7 @@ func Without[T comparable, I ~func(func(T) bool)](collection I, exclude ...T) I // WithoutBy filters a sequence by excluding elements whose extracted keys match any in the exclude list. // Returns a sequence containing only the elements whose keys are not in the exclude list. // Will allocate a map large enough to hold all distinct excludes. +// Play: https://go.dev/play/p/Hm734hnLnLI func WithoutBy[T any, K comparable, I ~func(func(T) bool)](collection I, transform func(item T) K, exclude ...K) I { set := lo.Keyify(exclude) return Reject(collection, func(item T) bool { return lo.HasKey(set, transform(item)) }) @@ -247,6 +249,7 @@ func WithoutBy[T any, K comparable, I ~func(func(T) bool)](collection I, transfo // WithoutNth returns a sequence excluding the nth value. // Will allocate a map large enough to hold all distinct nths. +// Play: https://go.dev/play/p/KGE7Lpsk18P func WithoutNth[T comparable, I ~func(func(T) bool)](collection I, nths ...int) I { set := lo.Keyify(nths) return RejectI(collection, func(_ T, index int) bool { return lo.HasKey(set, index) }) @@ -257,7 +260,7 @@ func WithoutNth[T comparable, I ~func(func(T) bool)](collection I, nths ...int) // The order of elements is not checked. // Will iterate through each sequence before returning and allocate a map large enough to hold all distinct elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/yGpdBGaWPCA +// Play: https://go.dev/play/p/24SGQm1yMRe func ElementsMatch[T comparable](list1, list2 iter.Seq[T]) bool { return ElementsMatchBy(list1, list2, func(item T) T { return item }) } @@ -267,6 +270,7 @@ func ElementsMatch[T comparable](list1, list2 iter.Seq[T]) bool { // The order of elements is not checked. // Will iterate through each sequence before returning and allocate a map large enough to hold all distinct transformed elements. // Long heterogeneous input sequences can cause excessive memory usage. +// Play: https://go.dev/play/p/I3vFrmQo43E func ElementsMatchBy[T any, K comparable](list1, list2 iter.Seq[T], transform func(item T) K) bool { counters := make(map[K]int) diff --git a/it/map.go b/it/map.go index 87aa871..57d91aa 100644 --- a/it/map.go +++ b/it/map.go @@ -59,7 +59,7 @@ func Values[K comparable, V any](in ...map[K]V) iter.Seq[V] { // UniqValues creates a sequence of unique values in the map. // Will allocate a map large enough to hold all distinct input values. // Long input sequences with heterogeneous values can cause excessive memory usage. -// Play: https://go.dev/play/p/M7qV2xP4yG8 +// Play: https://go.dev/play/p/QQv4zGrk-fF func UniqValues[K, V comparable](in ...map[K]V) iter.Seq[V] { return func(yield func(V) bool) { seen := make(map[V]struct{}) @@ -78,7 +78,7 @@ func UniqValues[K, V comparable](in ...map[K]V) iter.Seq[V] { } // Entries transforms a map into a sequence of key/value pairs. -// Play: https://go.dev/play/p/N8RbJ5t6H2k +// Play: https://go.dev/play/p/ckLxqTE9KCz func Entries[K comparable, V any](in ...map[K]V) iter.Seq2[K, V] { return func(yield func(K, V) bool) { for _, m := range in { @@ -99,7 +99,7 @@ func ToPairs[K comparable, V any](in ...map[K]V) iter.Seq2[K, V] { } // FromEntries transforms a sequence of key/value pairs into a map. -// Play: https://go.dev/play/p/K3wL9j7TmXs +// Play: https://go.dev/play/p/MgEF1J5-tuK func FromEntries[K comparable, V any](entries ...iter.Seq2[K, V]) map[K]V { m := make(map[K]V) for _, e := range entries { @@ -110,13 +110,13 @@ func FromEntries[K comparable, V any](entries ...iter.Seq2[K, V]) map[K]V { // FromPairs transforms a sequence of key/value pairs into a map. // Alias of FromEntries(). -// Play: https://go.dev/play/p/K3wL9j7TmXs +// Play: https://go.dev/play/p/GqPl6isVR9W func FromPairs[K comparable, V any](entries ...iter.Seq2[K, V]) map[K]V { return FromEntries(entries...) } // Invert creates a sequence composed of inverted keys and values. -// Play: https://go.dev/play/p/H4jR7n2sF8k +// Play: https://go.dev/play/p/Iph19Lgcsx- func Invert[K, V comparable](in iter.Seq2[K, V]) iter.Seq2[V, K] { return func(yield func(V, K) bool) { for k, v := range in { @@ -128,7 +128,7 @@ func Invert[K, V comparable](in iter.Seq2[K, V]) iter.Seq2[V, K] { } // Assign merges multiple sequences of maps from left to right. -// Play: https://go.dev/play/p/P6tY8qW3rN2 +// Play: https://go.dev/play/p/lwngaIFkFAg func Assign[K comparable, V any, Map ~map[K]V](maps ...iter.Seq[Map]) Map { out := make(Map) @@ -145,7 +145,7 @@ func Assign[K comparable, V any, Map ~map[K]V](maps ...iter.Seq[Map]) Map { // ChunkEntries splits a map into a sequence of elements in groups of length equal to its size. If the map cannot be split evenly, // the final chunk will contain the remaining elements. -// Play: https://go.dev/play/p/Q4jR8m9T2nX +// Play: https://go.dev/play/p/xtX-so65kDp func ChunkEntries[K comparable, V any](m map[K]V, size int) iter.Seq[map[K]V] { if size <= 0 { panic("it.ChunkEntries: size must be greater than 0") @@ -172,7 +172,7 @@ func ChunkEntries[K comparable, V any](m map[K]V, size int) iter.Seq[map[K]V] { } // MapToSeq transforms a map into a sequence based on specified transform. -// Play: https://go.dev/play/p/R7sL5h4K3mV +// Play: https://go.dev/play/p/SEV4Vz5XFac func MapToSeq[K comparable, V, R any](in map[K]V, transform func(key K, value V) R) iter.Seq[R] { return func(yield func(R) bool) { for k, v := range in { @@ -187,7 +187,7 @@ func MapToSeq[K comparable, V, R any](in map[K]V, transform func(key K, value V) // The transform returns a value and a boolean. If the boolean is true, the value is added to the result sequence. // If the boolean is false, the value is not added to the result sequence. // The order of the keys in the input map is not specified and the order of the keys in the output sequence is not guaranteed. -// Play: https://go.dev/play/p/S6tY2uJ7nWq +// Play: https://go.dev/play/p/HQgi01x8A4o func FilterMapToSeq[K comparable, V, R any](in map[K]V, transform func(key K, value V) (R, bool)) iter.Seq[R] { return func(yield func(R) bool) { for k, v := range in { @@ -200,7 +200,7 @@ func FilterMapToSeq[K comparable, V, R any](in map[K]V, transform func(key K, va // FilterKeys transforms a map into a sequence based on predicate returns true for specific elements. // It is a mix of Filter and Keys. -// Play: https://go.dev/play/p/T8vW9kX7nLm +// Play: https://go.dev/play/p/ODxc6_IiWtO func FilterKeys[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) iter.Seq[K] { return func(yield func(K) bool) { for k, v := range in { @@ -213,7 +213,7 @@ func FilterKeys[K comparable, V any](in map[K]V, predicate func(key K, value V) // FilterValues transforms a map into a sequence based on predicate returns true for specific elements. // It is a mix of Filter and Values. -// Play: https://go.dev/play/p/U3yN7kV8oXp +// Play: https://go.dev/play/p/9SBiyOqgrl8 func FilterValues[K comparable, V any](in map[K]V, predicate func(key K, value V) bool) iter.Seq[V] { return func(yield func(V) bool) { for k, v := range in { diff --git a/it/math.go b/it/math.go index d499863..dcf8bc0 100644 --- a/it/math.go +++ b/it/math.go @@ -10,7 +10,7 @@ import ( ) // Range creates a sequence of numbers (positive and/or negative) with given length. -// Play: https://go.dev/play/p/6ksL0W6KEuQ +// Play: https://go.dev/play/p/79QUZBa8Ukn func Range(elementNum int) iter.Seq[int] { step := lo.Ternary(elementNum < 0, -1, 1) length := elementNum * step @@ -86,14 +86,14 @@ func SumBy[T any, R constraints.Float | constraints.Integer | constraints.Comple // Product gets the product of the values in a collection. If collection is empty 1 is returned. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/ebgxKxJmhLj +// Play: https://go.dev/play/p/AOMCD1Yl5Bc func Product[T constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T]) T { return ProductBy(collection, func(item T) T { return item }) } // ProductBy summarizes the values in a collection using the given return value from the iteration function. If collection is empty 1 is returned. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/BkRYS0NG42b +// Play: https://go.dev/play/p/dgFCRJrlPHY func ProductBy[T any, R constraints.Float | constraints.Integer | constraints.Complex](collection iter.Seq[T], transform func(item T) R) R { var product R = 1 for item := range collection { diff --git a/it/seq.go b/it/seq.go index 11b8bae..443ef1e 100644 --- a/it/seq.go +++ b/it/seq.go @@ -50,7 +50,7 @@ func FilterI[T any, I ~func(func(T) bool)](collection I, predicate func(item T, } // Map manipulates a sequence and transforms it to a sequence of another type. -// Play: https://go.dev/play/p/rWZiPB-RZOo +// Play: https://go.dev/play/p/F_FkOP-9F9T func Map[T, R any](collection iter.Seq[T], transform func(item T) R) iter.Seq[R] { return MapI(collection, func(item T, _ int) R { return transform(item) }) } @@ -90,7 +90,7 @@ func UniqMapI[T any, R comparable](collection iter.Seq[T], transform func(item T // - the result of the mapping operation and // - whether the result element should be included or not. // -// Play: https://go.dev/play/p/9jthUzgF-u +// Play: https://go.dev/play/p/Gxwu8j_TJuh func FilterMap[T, R any](collection iter.Seq[T], callback func(item T) (R, bool)) iter.Seq[R] { return FilterMapI(collection, func(item T, _ int) (R, bool) { return callback(item) }) } @@ -116,7 +116,7 @@ func FilterMapI[T, R any](collection iter.Seq[T], callback func(item T, index in // FlatMap manipulates a sequence and transforms and flattens it to a sequence of another type. // The transform function can either return a sequence or a `nil`, and in the `nil` case // no value is yielded. -// Play: https://go.dev/play/p/1YsRLPl-wx +// Play: https://go.dev/play/p/6toB9w2gpSy func FlatMap[T, R any](collection iter.Seq[T], transform func(item T) iter.Seq[R]) iter.Seq[R] { return FlatMapI(collection, func(item T, _ int) iter.Seq[R] { return transform(item) }) } @@ -142,7 +142,7 @@ func FlatMapI[T, R any](collection iter.Seq[T], transform func(item T, index int // Reduce reduces collection to a value which is the accumulated result of running each element in collection // through accumulator, where each successive invocation is supplied the return value of the previous. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/FmkVUf39ZP_Y +// Play: https://go.dev/play/p/l5wWLATXclf func Reduce[T, R any](collection iter.Seq[T], accumulator func(agg R, item T) R, initial R) R { return ReduceI(collection, func(agg R, item T, _ int) R { return accumulator(agg, item) }, initial) } @@ -164,7 +164,7 @@ func ReduceI[T, R any](collection iter.Seq[T], accumulator func(agg R, item T, i // ReduceLast is like Reduce except that it iterates over elements of collection in reverse. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/4BvOSo-yza +// Play: https://go.dev/play/p/D2ZGZ2pN270 func ReduceLast[T, R any](collection iter.Seq[T], accumulator func(agg R, item T) R, initial R) R { return Reduce(Reverse(collection), accumulator, initial) } @@ -179,7 +179,7 @@ func ReduceLastI[T, R any](collection iter.Seq[T], accumulator func(agg R, item // ForEach iterates over elements of collection and invokes callback for each element. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/agIsKpG-S-P +// Play: https://go.dev/play/p/OvW9yNNYgsX func ForEach[T any](collection iter.Seq[T], callback func(item T)) { ForEachI(collection, func(item T, _ int) { callback(item) }) } @@ -198,7 +198,7 @@ func ForEachI[T any](collection iter.Seq[T], callback func(item T, index int)) { // ForEachWhile iterates over elements of collection and invokes predicate for each element // collection return value decide to continue or break, like do while(). // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/7OiBF1-zn +// Play: https://go.dev/play/p/UsfPR_gmSs7 func ForEachWhile[T any](collection iter.Seq[T], predicate func(item T) bool) { ForEachWhileI(collection, func(item T, _ int) bool { return predicate(item) }) } @@ -219,7 +219,7 @@ func ForEachWhileI[T any](collection iter.Seq[T], predicate func(item T, index i // Times invokes callback n times and returns a sequence of results. // The transform is invoked with index as argument. -// Play: https://go.dev/play/p/9QkDH3-zp +// Play: https://go.dev/play/p/0W4IRzQuCEc func Times[T any](count int, callback func(index int) T) iter.Seq[T] { return func(yield func(T) bool) { for i := range count { @@ -234,7 +234,7 @@ func Times[T any](count int, callback func(index int) T) iter.Seq[T] { // The order of result values is determined by the order they occur in the sequence. // Will allocate a map large enough to hold all distinct elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/0RlEI4-zq +// Play: https://go.dev/play/p/D-SenTW-ipj func Uniq[T comparable, I ~func(func(T) bool)](collection I) I { return UniqBy(collection, func(item T) T { return item }) } @@ -244,7 +244,7 @@ func Uniq[T comparable, I ~func(func(T) bool)](collection I) I { // invoked for each element in the sequence to generate the criterion by which uniqueness is computed. // Will allocate a map large enough to hold all distinct transformed elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/1SmFJ5-zr +// Play: https://go.dev/play/p/HKrt3AvwMTR func UniqBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform func(item T) U) I { return func(yield func(T) bool) { seen := make(map[U]struct{}) @@ -264,7 +264,7 @@ func UniqBy[T any, U comparable, I ~func(func(T) bool)](collection I, transform // GroupBy returns an object composed of keys generated from the results of running each element of collection through transform. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/oRIakS89OYy func GroupBy[T any, U comparable](collection iter.Seq[T], transform func(item T) U) map[U][]T { return GroupByMap(collection, func(item T) (U, T) { return transform(item), item }) } @@ -286,7 +286,7 @@ func GroupByMap[T any, K comparable, V any](collection iter.Seq[T], transform fu // Chunk returns a sequence of elements split into groups of length size. If the sequence can't be split evenly, // the final chunk will be the remaining elements. -// Play: https://go.dev/play/p/4VpIM8-zu +// Play: https://go.dev/play/p/qo8esZ_L60Q func Chunk[T any](collection iter.Seq[T], size int) iter.Seq[[]T] { if size <= 0 { panic("it.Chunk: size must be greater than 0") @@ -315,6 +315,7 @@ func Chunk[T any](collection iter.Seq[T], size int) iter.Seq[[]T] { // Window creates a sequence of sliding windows of a given size. // Each window overlaps with the previous one by size-1 elements. // This is equivalent to Sliding(collection, size, 1). +// Play: https://go.dev/play/p/_1BzQYtKBhi func Window[T any](collection iter.Seq[T], size int) iter.Seq[[]T] { if size <= 0 { panic("it.Window: size must be greater than 0") @@ -327,6 +328,7 @@ func Window[T any](collection iter.Seq[T], size int) iter.Seq[[]T] { // offset = step - size: offset == 0 means adjacent windows (no overlap/gap); // offset < 0 means overlapping windows; offset > 0 means gaps between windows. // Only full-size windows are yielded; a partial window at the end is not yielded. +// Play: https://go.dev/play/p/mzhO4CZeiik func Sliding[T any](collection iter.Seq[T], size, step int) iter.Seq[[]T] { if size <= 0 { panic("it.Sliding: size must be greater than 0") @@ -390,7 +392,7 @@ func Sliding[T any](collection iter.Seq[T], size, step int) iter.Seq[[]T] { // of running each element of collection through transform. // Will allocate a map large enough to hold all distinct transformed elements. // Long heterogeneous input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/5WqJN9-zv +// Play: https://go.dev/play/p/VxTx8mva28z func PartitionBy[T any, K comparable](collection iter.Seq[T], transform func(item T) K) [][]T { var result [][]T seen := map[K]int{} @@ -411,7 +413,7 @@ func PartitionBy[T any, K comparable](collection iter.Seq[T], transform func(ite } // Flatten returns a sequence a single level deep. -// Play: https://go.dev/play/p/6XrKO0-zw +// Play: https://go.dev/play/p/CCklxuNk7Lm func Flatten[T any, I ~func(func(T) bool)](collection []I) I { return func(yield func(T) bool) { for _, item := range collection { @@ -425,13 +427,14 @@ func Flatten[T any, I ~func(func(T) bool)](collection []I) I { } // Concat returns a sequence of all the elements in iterators. Concat conserves the order of the elements. +// Play: https://go.dev/play/p/Fa0u7xT2JOR func Concat[T any, I ~func(func(T) bool)](collection ...I) I { return Flatten(collection) } // Interleave round-robin alternating input sequences and sequentially appending value at index into result. // Will allocate a slice the size of collections. -// Play: https://go.dev/play/p/7YsLP1-zx +// Play: https://go.dev/play/p/kNvnz4ClLgH func Interleave[T any](collections ...iter.Seq[T]) iter.Seq[T] { return func(yield func(T) bool) { next := make([]func() (T, bool), len(collections)) @@ -484,7 +487,7 @@ func Reverse[T any, I ~func(func(T) bool)](collection I) I { } // Fill replaces elements of a sequence with `initial` value. -// Play: https://go.dev/play/p/0XrQKOk-vw +// Play: https://go.dev/play/p/mHShWq5ezMc func Fill[T lo.Clonable[T], I ~func(func(T) bool)](collection I, initial T) I { return func(yield func(T) bool) { for range collection { @@ -496,13 +499,13 @@ func Fill[T lo.Clonable[T], I ~func(func(T) bool)](collection I, initial T) I { } // Repeat builds a sequence with N copies of initial value. -// Play: https://go.dev/play/p/1YsRLPl-wx +// Play: https://go.dev/play/p/xs-aq0p_uDP func Repeat[T lo.Clonable[T]](count int, initial T) iter.Seq[T] { return RepeatBy(count, func(int) T { return initial.Clone() }) } // RepeatBy builds a sequence with values returned by N calls of transform. -// Play: https://go.dev/play/p/2ZtSMQm-xy +// Play: https://go.dev/play/p/i7BuZQBcUzZ func RepeatBy[T any](count int, callback func(index int) T) iter.Seq[T] { return func(yield func(T) bool) { for i := range count { @@ -515,7 +518,7 @@ func RepeatBy[T any](count int, callback func(index int) T) iter.Seq[T] { // KeyBy transforms a sequence to a map based on a pivot transform function. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/3AuTNRn-yz +// Play: https://go.dev/play/p/MMaHpzTqY0a func KeyBy[K comparable, V any](collection iter.Seq[V], transform func(item V) K) map[K]V { result := make(map[K]V) @@ -531,7 +534,7 @@ func KeyBy[K comparable, V any](collection iter.Seq[V], transform func(item V) K // If any of two pairs have the same key the last one gets added to the map. // The order of keys in returned map is not specified and is not guaranteed to be the same from the original sequence. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/4BvOSo-yza +// Play: https://go.dev/play/p/ayCImLr_4im func Associate[T any, K comparable, V any](collection iter.Seq[T], transform func(item T) (K, V)) map[K]V { return AssociateI(collection, func(item T, _ int) (K, V) { return transform(item) }) } @@ -608,7 +611,7 @@ func FilterSeqToMapI[T any, K comparable, V any](collection iter.Seq[T], transfo // Keyify returns a map with each unique element of the sequence as a key. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/0RlEI4-zq +// Play: https://go.dev/play/p/aHOD29_l-rF func Keyify[T comparable](collection iter.Seq[T]) map[T]struct{} { result := make(map[T]struct{}) @@ -620,7 +623,7 @@ func Keyify[T comparable](collection iter.Seq[T]) map[T]struct{} { } // Drop drops n elements from the beginning of a sequence. -// Play: https://go.dev/play/p/1SmFJ5-zr +// Play: https://go.dev/play/p/O1J1-uWc3z9 func Drop[T any, I ~func(func(T) bool)](collection I, n int) I { if n < 0 { panic("it.Drop: n must not be negative") @@ -635,7 +638,7 @@ func Drop[T any, I ~func(func(T) bool)](collection I, n int) I { // DropLast drops n elements from the end of a sequence. // Will allocate a slice of length n. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/-NzU5Px5Tp4 func DropLast[T any, I ~func(func(T) bool)](collection I, n int) I { if n < 0 { panic("it.DropLast: n must not be negative") @@ -663,7 +666,7 @@ func DropLast[T any, I ~func(func(T) bool)](collection I, n int) I { } // DropWhile drops elements from the beginning of a sequence while the predicate returns true. -// Play: https://go.dev/play/p/3UoHL7-zt +// Play: https://go.dev/play/p/zSM8x08a9QD func DropWhile[T any, I ~func(func(T) bool)](collection I, predicate func(item T) bool) I { return func(yield func(T) bool) { dropping := true @@ -679,7 +682,7 @@ func DropWhile[T any, I ~func(func(T) bool)](collection I, predicate func(item T // DropLastWhile drops elements from the end of a sequence while the predicate returns true. // Will allocate a slice large enough to hold the longest sequence of matching elements. // Long input sequences of consecutive matches can cause excessive memory usage. -// Play: https://go.dev/play/p/4VpIM8-zu +// Play: https://go.dev/play/p/qZ81Cq7R-Yt func DropLastWhile[T any, I ~func(func(T) bool)](collection I, predicate func(item T) bool) I { return func(yield func(T) bool) { var buf []T @@ -737,7 +740,7 @@ func TakeWhile[T any, I ~func(func(T) bool)](collection I, predicate func(item T // DropByIndex drops elements from a sequence by the index. // Will allocate a map large enough to hold all distinct indexes. -// Play: https://go.dev/play/p/5WqJN9-zv +// Play: https://go.dev/play/p/vPbrZYgiU4q func DropByIndex[T any, I ~func(func(T) bool)](collection I, indexes ...int) I { set := lo.Keyify(indexes) return RejectI(collection, func(_ T, index int) bool { return lo.HasKey(set, index) }) @@ -745,6 +748,7 @@ func DropByIndex[T any, I ~func(func(T) bool)](collection I, indexes ...int) I { // TakeFilter filters elements and takes the first n elements that match the predicate. // Equivalent to calling Take(Filter(...)), but more efficient as it stops after finding n matches. +// Play: https://go.dev/play/p/Db68Bhu4MCA func TakeFilter[T any, I ~func(func(T) bool)](collection I, n int, predicate func(item T) bool) I { return TakeFilterI(collection, n, func(item T, _ int) bool { return predicate(item) }) } @@ -776,7 +780,7 @@ func TakeFilterI[T any, I ~func(func(T) bool)](collection I, n int, predicate fu } // Reject is the opposite of Filter, this method returns the elements of collection that predicate does not return true for. -// Play: https://go.dev/play/p/6XrKO0-zw +// Play: https://go.dev/play/p/IIQcknFhZnq func Reject[T any, I ~func(func(T) bool)](collection I, predicate func(item T) bool) I { return RejectI(collection, func(item T, _ int) bool { return predicate(item) }) } @@ -800,7 +804,7 @@ func RejectI[T any, I ~func(func(T) bool)](collection I, predicate func(item T, // - the result of the mapping operation and // - whether the result element should be included or not. // -// Play: https://go.dev/play/p/8isgTsyfL-t +// Play: https://go.dev/play/p/51jRHVYscgi func RejectMap[T, R any](collection iter.Seq[T], callback func(item T) (R, bool)) iter.Seq[R] { return RejectMapI(collection, func(item T, _ int) (R, bool) { return callback(item) }) } @@ -825,14 +829,14 @@ func RejectMapI[T, R any](collection iter.Seq[T], callback func(item T, index in // Count counts the number of elements in the collection that equal value. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/0XrQKOk-vw +// Play: https://go.dev/play/p/UcJ-6cANwfY func Count[T comparable](collection iter.Seq[T], value T) int { return CountBy(collection, func(item T) bool { return item == value }) } // CountBy counts the number of elements in the collection for which predicate is true. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/1SmFJ5-zr +// Play: https://go.dev/play/p/m6G0o3huCOG func CountBy[T any](collection iter.Seq[T], predicate func(item T) bool) int { var count int @@ -847,7 +851,7 @@ func CountBy[T any](collection iter.Seq[T], predicate func(item T) bool) int { // CountValues counts the number of each element in the collection. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/PPBT4Fp-V3B func CountValues[T comparable](collection iter.Seq[T]) map[T]int { return CountValuesBy(collection, func(item T) T { return item }) } @@ -855,7 +859,7 @@ func CountValues[T comparable](collection iter.Seq[T]) map[T]int { // CountValuesBy counts the number of each element returned from transform function. // Is equivalent to chaining Map and CountValues. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/3UoHL7-zt +// Play: https://go.dev/play/p/gnr_MPhYCHX func CountValuesBy[T any, U comparable](collection iter.Seq[T], transform func(item T) U) map[U]int { result := make(map[U]int) @@ -868,7 +872,7 @@ func CountValuesBy[T any, U comparable](collection iter.Seq[T], transform func(i // Subset returns a subset of a sequence from `offset` up to `length` elements. // Will iterate at most offset+length times. -// Play: https://go.dev/play/p/4VpIM8-zu +// Play: https://go.dev/play/p/r-6FdqOL28Z func Subset[T any, I ~func(func(T) bool)](collection I, offset, length int) I { if offset < 0 { panic("it.Subset: offset must not be negative") @@ -882,7 +886,7 @@ func Subset[T any, I ~func(func(T) bool)](collection I, offset, length int) I { // Slice returns a subset of a sequence from `start` up to, but not including `end`. // Will iterate at most end times. -// Play: https://go.dev/play/p/5WqJN9-zv +// Play: https://go.dev/play/p/jKIu1oPf5hK func Slice[T any, I ~func(func(T) bool)](collection I, start, end int) I { if start < 0 { start = 0 @@ -903,7 +907,7 @@ func Slice[T any, I ~func(func(T) bool)](collection I, start, end int) I { } // Replace returns a sequence with the first n non-overlapping instances of old replaced by new. -// Play: https://go.dev/play/p/6XrKO0-zw +// Play: https://go.dev/play/p/aFXjeyf0KqV func Replace[T comparable, I ~func(func(T) bool)](collection I, old, nEw T, n int) I { return I(func(yield func(T) bool) { n := n @@ -918,27 +922,27 @@ func Replace[T comparable, I ~func(func(T) bool)](collection I, old, nEw T, n in } // ReplaceAll returns a sequence with all non-overlapping instances of old replaced by new. -// Play: https://go.dev/play/p/7YsLP1-zx +// Play: https://go.dev/play/p/sOckhMvvwjc func ReplaceAll[T comparable, I ~func(func(T) bool)](collection I, old, nEw T) I { return Replace(collection, old, nEw, -1) } // Compact returns a sequence of all non-zero elements. -// Play: https://go.dev/play/p/8isgTsyfL-t +// Play: https://go.dev/play/p/R_xT99w2QaU func Compact[T comparable, I ~func(func(T) bool)](collection I) I { return Filter(collection, lo.IsNotEmpty) } // IsSorted checks if a sequence is sorted. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/9jthUzgF-u +// Play: https://go.dev/play/p/o-BD4UOn-0U func IsSorted[T constraints.Ordered](collection iter.Seq[T]) bool { return IsSortedBy(collection, func(item T) T { return item }) } // IsSortedBy checks if a sequence is sorted by transform. // Will iterate through the entire sequence. -// Play: https://go.dev/play/p/0XrQKOk-vw +// Play: https://go.dev/play/p/AfYOiGWa78T func IsSortedBy[T any, K constraints.Ordered](collection iter.Seq[T], transform func(item T) K) bool { first := true var prev K @@ -955,7 +959,7 @@ func IsSortedBy[T any, K constraints.Ordered](collection iter.Seq[T], transform } // Splice inserts multiple elements at index i. The helper is protected against overflow errors. -// Play: https://go.dev/play/p/1SmFJ5-zr +// Play: https://go.dev/play/p/TevQSvDKO_i func Splice[T any, I ~func(func(T) bool)](collection I, index int, elements ...T) I { if index < 0 { panic("it.Splice: index must not be negative") @@ -995,7 +999,7 @@ func Splice[T any, I ~func(func(T) bool)](collection I, index int, elements ...T // If collection doesn't start with prefix, CutPrefix returns collection, false. // If prefix is empty, CutPrefix returns collection, true. // Will iterate at most the size of separator before returning. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/bPnV39zVnAV func CutPrefix[T comparable, I ~func(func(T) bool)](collection I, separator []T) (after I, found bool) { //nolint:gocyclo if len(separator) == 0 { return collection, true @@ -1050,7 +1054,7 @@ func CutPrefix[T comparable, I ~func(func(T) bool)](collection I, separator []T) // If suffix is empty, CutSuffix returns collection, true. // Will iterate through the entire sequence and allocate a slice large enough to hold all elements. // Long input sequences can cause excessive memory usage. -// Play: https://go.dev/play/p/3UoHL7-zt +// Play: https://go.dev/play/p/CTRh9m1UHrZ func CutSuffix[T comparable, I ~func(func(T) bool)](collection I, separator []T) (before I, found bool) { slice := slices.Collect(iter.Seq[T](collection)) result, ok := lo.CutSuffix(slice, separator) @@ -1059,7 +1063,7 @@ func CutSuffix[T comparable, I ~func(func(T) bool)](collection I, separator []T) // Trim removes all the leading and trailing cutset from the collection. // Will allocate a map large enough to hold all distinct cutset elements. -// Play: https://go.dev/play/p/4VpIM8-zu +// Play: https://go.dev/play/p/k0VCcilk4V1 func Trim[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I { predicate := lo.Partial(lo.HasKey, lo.Keyify(cutset)) return DropLastWhile(DropWhile(collection, predicate), predicate) @@ -1067,13 +1071,13 @@ func Trim[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I { // TrimFirst removes all the leading cutset from the collection. // Will allocate a map large enough to hold all distinct cutset elements. -// Play: https://go.dev/play/p/5WqJN9-zv +// Play: https://go.dev/play/p/4D4Ke5C5MwH func TrimFirst[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I { return DropWhile(collection, lo.Partial(lo.HasKey, lo.Keyify(cutset))) } // TrimPrefix removes all the leading prefix from the collection. -// Play: https://go.dev/play/p/6XrKO0-zw +// Play: https://go.dev/play/p/Pce4zSPnThY func TrimPrefix[T comparable, I ~func(func(T) bool)](collection I, prefix []T) I { n := len(prefix) if n == 0 { @@ -1112,13 +1116,13 @@ func TrimPrefix[T comparable, I ~func(func(T) bool)](collection I, prefix []T) I // TrimLast removes all the trailing cutset from the collection. // Will allocate a map large enough to hold all distinct cutset elements. -// Play: https://go.dev/play/p/7YsLP1-zx +// Play: https://go.dev/play/p/GQLhnaeW0gd func TrimLast[T comparable, I ~func(func(T) bool)](collection I, cutset ...T) I { return DropLastWhile(collection, lo.Partial(lo.HasKey, lo.Keyify(cutset))) } // TrimSuffix removes all the trailing suffix from the collection. -// Play: https://go.dev/play/p/8isgTsyfL-t +// Play: https://go.dev/play/p/s9nwy9helEi func TrimSuffix[T comparable, I ~func(func(T) bool)](collection I, suffix []T) I { n := len(suffix) if n == 0 { @@ -1161,6 +1165,7 @@ func TrimSuffix[T comparable, I ~func(func(T) bool)](collection I, suffix []T) I // Buffer returns a sequence of slices, each containing up to size items read from the channel. // The last slice may be smaller if the channel closes before filling the buffer. +// Play: https://go.dev/play/p/zDZdcCA20ut func Buffer[T any](seq iter.Seq[T], size int) iter.Seq[[]T] { return func(yield func([]T) bool) { buffer := make([]T, 0, size) diff --git a/it/string.go b/it/string.go index ab05393..4b8636e 100644 --- a/it/string.go +++ b/it/string.go @@ -6,7 +6,7 @@ import "iter" // ChunkString returns a sequence of strings split into groups of length size. If the string can't be split evenly, // the final chunk will be the remaining characters. -// Play: https://go.dev/play/p/Y4mN8bB2cXw +// Play: https://go.dev/play/p/Bcc5ixTQQoQ // // Note: it.ChunkString and it.Chunk functions behave inconsistently for empty input: it.ChunkString("", n) returns [""] instead of []. // See https://github.com/samber/lo/issues/788 diff --git a/it/tuples.go b/it/tuples.go index abe6712..9233a25 100644 --- a/it/tuples.go +++ b/it/tuples.go @@ -279,7 +279,7 @@ func Zip9[A, B, C, D, E, F, G, H, I any](a iter.Seq[A], b iter.Seq[B], c iter.Se // ZipBy2 creates a sequence of transformed elements, the first of which contains the first elements // of the given sequences, the second of which contains the second elements of the given sequences, and so on. // When collections are different sizes, the Tuple attributes are filled with zero value. -// Play: https://go.dev/play/p/2TnGK6-zs +// Play: https://go.dev/play/p/y03uqMEAi1E func ZipBy2[A, B, Out any](a iter.Seq[A], b iter.Seq[B], transform func(a A, b B) Out) iter.Seq[Out] { return Map(Zip2(a, b), func(item lo.Tuple2[A, B]) Out { return transform(item.A, item.B) @@ -359,7 +359,7 @@ func ZipBy9[A, B, C, D, E, F, G, H, I, Out any](a iter.Seq[A], b iter.Seq[B], c // CrossJoin2 combines every item from one list with every item from others. // It is the cartesian product of lists received as arguments. // Returns an empty list if a list is empty. -// Play: https://go.dev/play/p/ZBDEXBYj6nU +// Play: https://go.dev/play/p/OFe8xjZFjWU func CrossJoin2[A, B any](listA iter.Seq[A], listB iter.Seq[B]) iter.Seq[lo.Tuple2[A, B]] { return CrossJoinBy2(listA, listB, lo.T2[A, B]) } @@ -424,7 +424,7 @@ func CrossJoin9[A, B, C, D, E, F, G, H, I any](listA iter.Seq[A], listB iter.Seq // It is the cartesian product of lists received as arguments. The transform function // is used to create the output values. // Returns an empty list if a list is empty. -// Play: https://go.dev/play/p/7YsLP1-zx +// Play: https://go.dev/play/p/6QGp3W-bQU1 func CrossJoinBy2[A, B, Out any](listA iter.Seq[A], listB iter.Seq[B], transform func(a A, b B) Out) iter.Seq[Out] { return func(yield func(Out) bool) { for a := range listA { diff --git a/it/type_manipulation.go b/it/type_manipulation.go index e3f6702..663d03d 100644 --- a/it/type_manipulation.go +++ b/it/type_manipulation.go @@ -9,33 +9,33 @@ import ( ) // ToSeqPtr returns a sequence of pointers to each value. -// Play: https://go.dev/play/p/Z9nA8cC3dXw +// Play: https://go.dev/play/p/70BcKpDcOKm func ToSeqPtr[T any](collection iter.Seq[T]) iter.Seq[*T] { return Map(collection, lo.ToPtr) } // FromSeqPtr returns a sequence with the pointer values. // Returns a zero value in case of a nil pointer element. -// Play: https://go.dev/play/p/A1bB9dD4eYx +// Play: https://go.dev/play/p/_eO6scpLcBF func FromSeqPtr[T any](collection iter.Seq[*T]) iter.Seq[T] { return Map(collection, lo.FromPtr) } // FromSeqPtrOr returns a sequence with the pointer values or the fallback value. -// Play: https://go.dev/play/p/B2cC8eE5fYz +// Play: https://go.dev/play/p/LJ17S4pvOjo func FromSeqPtrOr[T any](collection iter.Seq[*T], fallback T) iter.Seq[T] { return Map(collection, func(x *T) T { return lo.FromPtrOr(x, fallback) }) } // ToAnySeq returns a sequence with all elements mapped to `any` type. -// Play: https://go.dev/play/p/C3dD9fF6Za1 +// Play: https://go.dev/play/p/ktE4IMXDMxv func ToAnySeq[T any](collection iter.Seq[T]) iter.Seq[any] { return Map(collection, func(x T) any { return x }) } // FromAnySeq returns a sequence with all elements mapped to a type. // Panics on type conversion failure. -// Play: https://go.dev/play/p/D4eE0gG7Ab2 +// Play: https://go.dev/play/p/wnOma1j5Uzu func FromAnySeq[T any](collection iter.Seq[any]) iter.Seq[T] { return Map(collection, func(item any) T { if t, ok := item.(T); ok { @@ -46,14 +46,14 @@ func FromAnySeq[T any](collection iter.Seq[any]) iter.Seq[T] { } // Empty returns an empty sequence. -// Play: https://go.dev/play/p/E5fF1hH8Bc3 +// Play: https://go.dev/play/p/Y9yplM3vGFe func Empty[T any]() iter.Seq[T] { return func(yield func(T) bool) {} } // IsEmpty returns true if the sequence is empty. // Will iterate at most once. -// Play: https://go.dev/play/p/F6gG2iI9Cd4 +// Play: https://go.dev/play/p/krZ-laaVi2C func IsEmpty[T any](collection iter.Seq[T]) bool { for range collection { return false @@ -63,14 +63,14 @@ func IsEmpty[T any](collection iter.Seq[T]) bool { // IsNotEmpty returns true if the sequence is not empty. // Will iterate at most once. -// Play: https://go.dev/play/p/G7hH3jJ0De5 +// Play: https://go.dev/play/p/jMAjbDvrdPu func IsNotEmpty[T any](collection iter.Seq[T]) bool { return !IsEmpty(collection) } // CoalesceSeq returns the first non-empty sequence. // Will iterate through each sub-sequence at most once. -// Play: https://go.dev/play/p/H8iI4kK1Ef6 +// Play: https://go.dev/play/p/wep4z2KJLCO func CoalesceSeq[T any](v ...iter.Seq[T]) (iter.Seq[T], bool) { for i := range v { for range v[i] { @@ -82,7 +82,7 @@ func CoalesceSeq[T any](v ...iter.Seq[T]) (iter.Seq[T], bool) { // CoalesceSeqOrEmpty returns the first non-empty sequence. // Will iterate through each sub-sequence at most once. -// Play: https://go.dev/play/p/I9jJ5lL2Fg7 +// Play: https://go.dev/play/p/3KZPAFRQr8B func CoalesceSeqOrEmpty[T any](v ...iter.Seq[T]) iter.Seq[T] { result, _ := CoalesceSeq(v...) return result diff --git a/map.go b/map.go index e5c90e6..69d26be 100644 --- a/map.go +++ b/map.go @@ -141,7 +141,7 @@ func PickByKeys[K comparable, V any, Map ~map[K]V](in Map, keys []K) Map { } // PickByValues returns same map type filtered by given values. -// Play: https://go.dev/play/p/1zdzSvbfsJc +// Play: https://go.dev/play/p/-_PPkSbO1Kc func PickByValues[K, V comparable, Map ~map[K]V](in Map, values []V) Map { r := Map{} @@ -395,7 +395,7 @@ func MapEntriesErr[K1 comparable, V1 any, K2 comparable, V2 any](in map[K1]V1, i } // MapToSlice transforms a map into a slice based on specified iteratee. -// Play: https://go.dev/play/p/ZuiCZpDt6LD +// Play: https://go.dev/play/p/4f5hbHyMf5h func MapToSlice[K comparable, V, R any](in map[K]V, iteratee func(key K, value V) R) []R { result := make([]R, 0, len(in)) @@ -444,6 +444,7 @@ func FilterMapToSlice[K comparable, V, R any](in map[K]V, iteratee func(key K, v // If the boolean is false, the value is not added to the result slice. // If an error is returned, iteration stops immediately and returns the error. // The order of the keys in the input map is not specified and the order of the keys in the output slice is not guaranteed. +// Play: https://go.dev/play/p/YjFEORLBWvk func FilterMapToSliceErr[K comparable, V, R any](in map[K]V, iteratee func(key K, value V) (R, bool, error)) ([]R, error) { result := make([]R, 0, len(in)) @@ -495,6 +496,7 @@ func FilterValues[K comparable, V any](in map[K]V, predicate func(key K, value V // If the predicate returns true, the key is added to the result slice. // If the predicate returns an error, iteration stops immediately and returns the error. // The order of the keys in the input map is not specified. +// Play: https://go.dev/play/p/j2gUQzCTu4t func FilterKeysErr[K comparable, V any](in map[K]V, predicate func(key K, value V) (bool, error)) ([]K, error) { result := make([]K, 0) @@ -516,6 +518,7 @@ func FilterKeysErr[K comparable, V any](in map[K]V, predicate func(key K, value // If the predicate returns true, the value is added to the result slice. // If the predicate returns an error, iteration stops immediately and returns the error. // The order of the keys in the input map is not specified. +// Play: https://go.dev/play/p/hKvHlqLzbdE func FilterValuesErr[K comparable, V any](in map[K]V, predicate func(key K, value V) (bool, error)) ([]V, error) { result := make([]V, 0) diff --git a/math.go b/math.go index f08f227..133104b 100644 --- a/math.go +++ b/math.go @@ -7,7 +7,7 @@ import ( ) // Range creates a slice of numbers (positive and/or negative) with given length. -// Play: https://go.dev/play/p/0r6VimXAi9H +// Play: https://go.dev/play/p/rho00R0WuHs func Range(elementNum int) []int { step := Ternary(elementNum < 0, -1, 1) length := elementNum * step @@ -187,6 +187,7 @@ func MeanByErr[T any, R constraints.Float | constraints.Integer](collection []T, // Mode returns the mode (most frequent value) of a collection. // If multiple values have the same highest frequency, then multiple values are returned. // If the collection is empty, then the zero value of T is returned. +// Play: https://go.dev/play/p/PbiviqnV5zX func Mode[T constraints.Integer | constraints.Float](collection []T) []T { length := T(len(collection)) if length == 0 { diff --git a/parallel/slice.go b/parallel/slice.go index 2d06f6d..948bcd2 100644 --- a/parallel/slice.go +++ b/parallel/slice.go @@ -46,6 +46,7 @@ func ForEach[T any](collection []T, callback func(item T, index int)) { // Times invokes the iteratee n times, returning a slice of the results of each invocation. // The iteratee is invoked with index as argument. // `iteratee` is called in parallel. +// Play: https://go.dev/play/p/ZNnWNcJ4Au- func Times[T any](count int, iteratee func(index int) T) []T { result := make([]T, count) @@ -70,6 +71,7 @@ func Times[T any](count int, iteratee func(index int) T) []T { // GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee. // The order of grouped values is determined by the order they occur in the collection. // `iteratee` is called in parallel. +// Play: https://go.dev/play/p/EkyvA0gw4dj func GroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) U) map[U]Slice { result := map[U]Slice{} @@ -89,6 +91,7 @@ func GroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(it // of running each element of collection through iteratee. // The order of groups is determined by their first appearance in the collection. // `iteratee` is called in parallel. +// Play: https://go.dev/play/p/GwBQdMgx2nC func PartitionBy[T any, K comparable, Slice ~[]T](collection Slice, iteratee func(item T) K) []Slice { result := []Slice{} seen := map[K]int{} diff --git a/retry.go b/retry.go index a4779f6..7c400bc 100644 --- a/retry.go +++ b/retry.go @@ -52,7 +52,7 @@ func (d *debounce) cancel() { } // NewDebounce creates a debounced instance that delays invoking functions given until after wait milliseconds have elapsed. -// Play: https://go.dev/play/p/mz32VMK2nqe +// Play: https://go.dev/play/p/_IPY7ROzbMk func NewDebounce(duration time.Duration, f ...func()) (func(), func()) { d := &debounce{ after: duration, @@ -135,7 +135,7 @@ func (d *debounceBy[T]) cancel(key T) { } // NewDebounceBy creates a debounced instance for each distinct key, that delays invoking functions given until after wait milliseconds have elapsed. -// Play: https://go.dev/play/p/d3Vpt6pxhY8 +// Play: https://go.dev/play/p/Izk7GEzZm2Q func NewDebounceBy[T comparable](duration time.Duration, f ...func(key T, count int)) (func(key T), func(key T)) { d := &debounceBy[T]{ after: duration, @@ -251,7 +251,7 @@ type transactionStep[T any] struct { } // NewTransaction instantiate a new transaction. -// Play: https://go.dev/play/p/Qxrd7MGQGh1 +// Play: https://go.dev/play/p/7B2o52wEQbj func NewTransaction[T any]() *Transaction[T] { return &Transaction[T]{ steps: []transactionStep[T]{}, diff --git a/slice.go b/slice.go index 492a3ed..8c8565d 100644 --- a/slice.go +++ b/slice.go @@ -301,6 +301,7 @@ func GroupBy[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(it // GroupByErr returns an object composed of keys generated from the results of running each element of collection through iteratee. // It returns the first error returned by the iteratee function. +// Play: https://go.dev/play/p/BzKPcY3AdX2 func GroupByErr[T any, U comparable, Slice ~[]T](collection Slice, iteratee func(item T) (U, error)) (map[U]Slice, error) { result := map[U]Slice{} @@ -449,6 +450,7 @@ func Flatten[T any, Slice ~[]T](collection []Slice) Slice { // Concat returns a new slice containing all the elements in collections. Concat conserves the order of the elements. // See also: Flatten, Union. +// Play: https://go.dev/play/p/Ux2UuR2xpRK func Concat[T any, Slice ~[]T](collections ...Slice) Slice { return Flatten(collections) } @@ -466,6 +468,7 @@ func Window[T any, Slice ~[]T](collection Slice, size int) []Slice { // Sliding creates a slice of sliding windows of a given size with a given step. // If step is equal to size, windows don't overlap (similar to Chunk). // If step is less than size, windows overlap. +// Play: https://go.dev/play/p/aIIU6gWxl2T func Sliding[T any, Slice ~[]T](collection Slice, size, step int) []Slice { if size <= 0 { panic("lo.Sliding: size must be greater than 0") @@ -492,7 +495,7 @@ func Sliding[T any, Slice ~[]T](collection Slice, size, step int) []Slice { } // Interleave round-robin alternating input slices and sequentially appending value at index into result. -// Play: https://go.dev/play/p/-RJkTLQEDVt +// Play: https://go.dev/play/p/KOVtGUt-tdI func Interleave[T any, Slice ~[]T](collections ...Slice) Slice { if len(collections) == 0 { return Slice{} @@ -676,7 +679,7 @@ func SliceToMapI[T any, K comparable, V any](collection []T, transform func(item // If any of two pairs have the same key the last one gets added to the map. // The order of keys in returned map is not specified and is not guaranteed to be the same from the original slice. // The third return value of the transform function is a boolean that indicates whether the key-value pair should be included in the map. -// Play: https://go.dev/play/p/2z0rDz2ZSGU +// Play: https://go.dev/play/p/eurMiQEqey2 func FilterSliceToMap[T any, K comparable, V any](collection []T, transform func(item T) (K, V, bool)) map[K]V { return FilterSliceToMapI(collection, func(item T, _ int) (K, V, bool) { return transform(item) @@ -702,7 +705,7 @@ func FilterSliceToMapI[T any, K comparable, V any](collection []T, transform fun } // Keyify returns a map with each unique element of the slice as a key. -// Play: https://go.dev/play/p/RYhhM_csqIG +// Play: https://go.dev/play/p/_d5lXdzfw32 func Keyify[T comparable, Slice ~[]T](collection Slice) map[T]struct{} { result := make(map[T]struct{}, len(collection)) @@ -745,7 +748,7 @@ func DropRight[T any, Slice ~[]T](collection Slice, n int) Slice { } // DropWhile drops elements from the beginning of a slice while the predicate returns true. -// Play: https://go.dev/play/p/7gBPYw2IK16 +// Play: https://go.dev/play/p/b_PYomVQLGy func DropWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice { i := 0 for ; i < len(collection); i++ { @@ -759,7 +762,7 @@ func DropWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) } // DropRightWhile drops elements from the end of a slice while the predicate returns true. -// Play: https://go.dev/play/p/3-n71oEC0Hz +// Play: https://go.dev/play/p/HBh8pHl-ZZz func DropRightWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice { i := len(collection) - 1 for ; i >= 0; i-- { @@ -799,6 +802,7 @@ func Take[T any, Slice ~[]T](collection Slice, n int) Slice { } // TakeWhile takes elements from the beginning of a slice while the predicate returns true. +// Play: https://go.dev/play/p/NJkLGvyRWm4 func TakeWhile[T any, Slice ~[]T](collection Slice, predicate func(item T) bool) Slice { i := 0 for ; i < len(collection); i++ { @@ -854,6 +858,7 @@ func DropByIndex[T any, Slice ~[]T](collection Slice, indexes ...int) Slice { // TakeFilter filters elements and takes the first n elements that match the predicate. // Equivalent to calling Take(Filter(...)), but more efficient as it stops after finding n matches. +// Play: https://go.dev/play/p/l99lvN4gReF func TakeFilter[T any, Slice ~[]T](collection Slice, n int, predicate func(item T, index int) bool) Slice { if n < 0 { panic("lo.TakeFilter: n must not be negative") @@ -880,7 +885,7 @@ func TakeFilter[T any, Slice ~[]T](collection Slice, n int, predicate func(item } // Reject is the opposite of Filter, this method returns the elements of collection that predicate does not return true for. -// Play: https://go.dev/play/p/pFCF5WVB225 +// Play: https://go.dev/play/p/7Pl-34c19Va func Reject[T any, Slice ~[]T](collection Slice, predicate func(item T, index int) bool) Slice { result := make(Slice, 0, len(collection)) @@ -963,7 +968,7 @@ func Count[T comparable](collection []T, value T) int { } // CountBy counts the number of elements in the collection for which predicate is true. -// Play: https://go.dev/play/p/ByQbNYQQi4X +// Play: https://go.dev/play/p/5GMQP5vNT4q func CountBy[T any](collection []T, predicate func(item T) bool) int { var count int @@ -978,6 +983,7 @@ func CountBy[T any](collection []T, predicate func(item T) bool) int { // CountByErr counts the number of elements in the collection for which predicate is true. // It returns the first error returned by the predicate. +// Play: https://go.dev/play/p/7BnyPhpG6lW func CountByErr[T any](collection []T, predicate func(item T) (bool, error)) (int, error) { var count int @@ -1088,6 +1094,7 @@ func ReplaceAll[T comparable, Slice ~[]T](collection Slice, old, nEw T) Slice { } // Clone returns a shallow copy of the collection. +// Play: https://go.dev/play/p/66LJ2wAF0rN func Clone[T any, Slice ~[]T](collection Slice) Slice { // backporting from slices.Clone in Go 1.21 // when we drop support for Go 1.20, this can be replaced with: return slices.Clone(collection) @@ -1203,7 +1210,7 @@ func Cut[T comparable, Slice ~[]T](collection, separator Slice) (before, after S // and reports whether it found the prefix. // If s doesn't start with prefix, CutPrefix returns collection, false. // If prefix is the empty []T, CutPrefix returns collection, true. -// Play: https://go.dev/play/p/7Plak4a1ICl +// Play: https://go.dev/play/p/P1scQj53aFa func CutPrefix[T comparable, Slice ~[]T](collection, separator Slice) (after Slice, found bool) { if HasPrefix(collection, separator) { return collection[len(separator):], true @@ -1223,7 +1230,7 @@ func CutSuffix[T comparable, Slice ~[]T](collection, separator Slice) (before Sl } // Trim removes all the leading and trailing cutset from the collection. -// Play: https://go.dev/play/p/1an9mxLdRG5 +// Play: https://go.dev/play/p/LZLfLj5C8Lg func Trim[T comparable, Slice ~[]T](collection, cutset Slice) Slice { set := Keyify(cutset) @@ -1250,7 +1257,7 @@ func Trim[T comparable, Slice ~[]T](collection, cutset Slice) Slice { } // TrimLeft removes all the leading cutset from the collection. -// Play: https://go.dev/play/p/74aqfAYLmyi +// Play: https://go.dev/play/p/fJK-AhROy9w func TrimLeft[T comparable, Slice ~[]T](collection, cutset Slice) Slice { set := Keyify(cutset) @@ -1261,7 +1268,7 @@ func TrimLeft[T comparable, Slice ~[]T](collection, cutset Slice) Slice { } // TrimPrefix removes all the leading prefix from the collection. -// Play: https://go.dev/play/p/SHO6X-YegPg +// Play: https://go.dev/play/p/8O2RoWYzi8J func TrimPrefix[T comparable, Slice ~[]T](collection, prefix Slice) Slice { if len(prefix) == 0 { return collection @@ -1275,7 +1282,7 @@ func TrimPrefix[T comparable, Slice ~[]T](collection, prefix Slice) Slice { } // TrimRight removes all the trailing cutset from the collection. -// Play: https://go.dev/play/p/MRpAfR6sf0g +// Play: https://go.dev/play/p/9V_N8sRyyiZ func TrimRight[T comparable, Slice ~[]T](collection, cutset Slice) Slice { set := Keyify(cutset) diff --git a/string.go b/string.go index 9b0fc6e..ed7ad18 100644 --- a/string.go +++ b/string.go @@ -105,7 +105,7 @@ func nearestPowerOfTwo(capacity int) int { // length - number of characters to extract // With positive offset, counting starts from the beginning of the string // With negative offset, counting starts from the end of the string -// Play: https://go.dev/play/p/TQlxQi82Lu1 +// Play: https://go.dev/play/p/emzCC9zBjHu func Substring[T ~string](str T, offset int, length uint) T { str = substring(str, offset, length) @@ -221,13 +221,13 @@ func ChunkString[T ~string](str T, size int) []T { } // RuneLength is an alias to utf8.RuneCountInString which returns the number of runes in string. -// Play: https://go.dev/play/p/tuhgW_lWY8l +// Play: https://go.dev/play/p/BXT52mBk0zO func RuneLength(str string) int { return utf8.RuneCountInString(str) } // PascalCase converts string to pascal case. -// Play: https://go.dev/play/p/Dy_V_6DUYhe +// Play: https://go.dev/play/p/uxER7XpRHLB func PascalCase(str string) string { items := Words(str) for i := range items { @@ -237,7 +237,7 @@ func PascalCase(str string) string { } // CamelCase converts string to camel case. -// Play: https://go.dev/play/p/Go6aKwUiq59 +// Play: https://go.dev/play/p/4JNDzaMwXkm func CamelCase(str string) string { items := Words(str) for i, item := range items { @@ -251,7 +251,7 @@ func CamelCase(str string) string { } // KebabCase converts string to kebab case. -// Play: https://go.dev/play/p/96gT_WZnTVP +// Play: https://go.dev/play/p/ZBeMB4-pq45 func KebabCase(str string) string { items := Words(str) for i := range items { diff --git a/time.go b/time.go index a2b1c7e..64f51f6 100644 --- a/time.go +++ b/time.go @@ -5,7 +5,7 @@ import ( ) // Duration returns the time taken to execute a function. -// Play: https://go.dev/play/p/HQfbBbAXaFP +// Play: https://go.dev/play/p/LFhKq2vY9Ty func Duration(callback func()) time.Duration { return Duration0(callback) } diff --git a/tuples.go b/tuples.go index 1911f8d..3712cbf 100644 --- a/tuples.go +++ b/tuples.go @@ -646,7 +646,7 @@ func ZipByErr9[A, B, C, D, E, F, G, H, I, Out any](a []A, b []B, c []C, d []D, e // Unzip2 accepts a slice of grouped elements and creates a slice regrouping the elements // to their pre-zip configuration. -// Play: https://go.dev/play/p/ciHugugvaAW +// Play: https://go.dev/play/p/K-vG9tyD3Kf func Unzip2[A, B any](tuples []Tuple2[A, B]) ([]A, []B) { size := len(tuples) r1 := make([]A, 0, size) @@ -1023,6 +1023,7 @@ func UnzipBy9[In, A, B, C, D, E, F, G, H, I any](items []In, iteratee func(In) ( // UnzipByErr2 iterates over a collection and creates a slice regrouping the elements // to their pre-zip configuration. // It returns the first error returned by the iteratee. +// Play: https://go.dev/play/p/G2pyXQa1SUD func UnzipByErr2[In, A, B any](items []In, iteratee func(In) (a A, b B, err error)) ([]A, []B, error) { size := len(items) r1 := make([]A, 0, size) @@ -1239,7 +1240,7 @@ func UnzipByErr9[In, A, B, C, D, E, F, G, H, I any](items []In, iteratee func(In // CrossJoin2 combines every item from one list with every item from others. // It is the cartesian product of lists received as arguments. // Returns an empty list if a list is empty. -// Play: https://go.dev/play/p/3VFppyL9FDU +// Play: https://go.dev/play/p/LSRL5DmdPag func CrossJoin2[A, B any](listA []A, listB []B) []Tuple2[A, B] { return CrossJoinBy2(listA, listB, T2[A, B]) } @@ -1304,7 +1305,7 @@ func CrossJoin9[A, B, C, D, E, F, G, H, I any](listA []A, listB []B, listC []C, // It is the cartesian product of lists received as arguments. The transform function // is used to create the output values. // Returns an empty list if a list is empty. -// Play: https://go.dev/play/p/8Y7btpvuA-C +// Play: https://go.dev/play/p/VLy8iyrPN8X func CrossJoinBy2[A, B, Out any](listA []A, listB []B, transform func(a A, b B) Out) []Out { size := len(listA) * len(listB) if size == 0 {