mutable

package
v1.49.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 1 Imported by: 15

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reverse

func Reverse[T any, Slice ~[]T](collection Slice)

Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on. Play: https://go.dev/play/p/iv2e9jslfBM

Example
list := []int{0, 1, 2, 3, 4, 5}

Reverse(list)

fmt.Printf("%v", list)
Output:

[5 4 3 2 1 0]

func Shuffle

func Shuffle[T any, Slice ~[]T](collection Slice)

Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm. Play: https://go.dev/play/p/ZTGG7OUCdnp

Example
list := []int{0, 1, 2, 3, 4, 5}

Shuffle(list)

fmt.Printf("%v", list)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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