seq2

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flip

func Flip[T any, U any](input iter.Seq2[T, U]) iter.Seq2[U, T]

Flip swaps the elements of a given sequence of pairs.

Example (Build_map)
package main

import (
	"fmt"
	"maps"
	"slices"

	"github.com/aereal/iter/seq2"
)

func main() {
	strs := []string{"a", "b", "c"}
	str2index := maps.Collect(seq2.Flip(slices.All(strs)))
	fmt.Println("map[string]int:")
	for _, str := range slices.Sorted(maps.Keys(str2index)) {
		fmt.Printf("%s=%d\n", str, str2index[str])
	}
}
Output:

map[string]int:
a=0
b=1
c=2

Types

This section is empty.

Jump to

Keyboard shortcuts

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