package main

import (
	"fmt"
	"slices"
)

func main() {
	// section: example
	numbers := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

	// slices.Chunk returns an iterator over contiguous sub-slices
	// of up to n elements each
	fmt.Println("Original:", numbers)
	fmt.Println("Chunks of 3:")
	for chunk := range slices.Chunk(numbers, 3) {
		fmt.Printf("  %v\n", chunk)
	}

	// Useful for batch processing
	fmt.Println("Chunks of 4:")
	for chunk := range slices.Chunk(numbers, 4) {
		fmt.Printf("  %v\n", chunk)
	}
	// section: example
}
