mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
31 lines
694 B
Markdown
31 lines
694 B
Markdown
---
|
|
name: Interleave
|
|
slug: interleave
|
|
sourceRef: slice.go#L282
|
|
category: core
|
|
subCategory: slice
|
|
playUrl: https://go.dev/play/p/KOVtGUt-tdI
|
|
variantHelpers:
|
|
- core#slice#interleave
|
|
similarHelpers:
|
|
- core#slice#flatten
|
|
- core#slice#chunk
|
|
- core#slice#slice
|
|
- core#slice#shuffle
|
|
position: 170
|
|
signatures:
|
|
- "func Interleave[T any, Slice ~[]T](collections ...Slice) Slice"
|
|
---
|
|
|
|
Round-robins input slices by index, appending values sequentially into the result.
|
|
|
|
```go
|
|
lo.Interleave([]int{1, 4, 7}, []int{2, 5, 8}, []int{3, 6, 9})
|
|
// []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
|
|
|
|
lo.Interleave([]int{1}, []int{2, 5, 8}, []int{3, 6}, []int{4, 7, 9, 10})
|
|
// []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
|
```
|
|
|
|
|