slices

package
v2.0.0-alpha.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package slices provides early implementations of slice-related functions available in Go 1.23+.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect[E any](seq iter.Seq[E]) []E

Collect collects values from seq into a new slice and returns it.

Example
package main

import (
	"fmt"

	"github.com/BooleanCat/go-functional/v2/future/slices"
)

func main() {
	fmt.Println(slices.Collect(slices.Values([]int{1, 2, 3})))
}
Output:

[1 2 3]

func Values

func Values[Slice ~[]E, E any](slice Slice) iter.Seq[E]

Values returns an iterator over the slice elements, starting with s[0].

Example
package main

import (
	"fmt"

	"github.com/BooleanCat/go-functional/v2/future/slices"
)

func main() {
	for number := range slices.Values([]int{1, 2, 3}) {
		fmt.Println(number)
	}

}
Output:

1
2
3

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL