github.com/enetx/g@v1.0.80/examples/iter/iter_partition.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/enetx/g"
     7  	"github.com/enetx/g/f"
     8  )
     9  
    10  func main() {
    11  	evens, odds := g.SliceOf(1, 2, 3, 4, 5).
    12  		Iter().
    13  		Partition(f.Even)
    14  
    15  	fmt.Println("Even numbers:", evens) // Output: Even numbers: Slice[2, 4]
    16  	fmt.Println("Odd numbers:", odds)   // Output: Odd numbers: Slice[1, 3, 5]
    17  }