Skip to content

Tuple

tuple package implements tuple data type and some operations on it.

Source:

Usage:

go
import (
    "github.com/duke-git/lancet/v2/pointer"
)

Index

Documentation

Tuple2

Tuple2 represents a 2 elemnets tuple.

Signature:

go
type Tuple2[A any, B any] struct {
    FieldA A
    FieldB B
}

func NewTuple2[A any, B any](a A, b B) Tuple2[A, B]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple2(1, 0.1)
    fmt.Printf("%v %v", t.FieldA, t.FieldB)

    // Output: 1 0.1
}

Tuple2_Unbox

Tuple2 Unbox returns values in tuple.

Signature:

go
func (t Tuple2[A, B]) Unbox() (A, B)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple2(1, 0.1)
    v1, v2 := t.Unbox()
    fmt.Printf("%v %v", v1, v2)

    // Output: 1 0.1
}

Zip2

Create a slice of Tuple2, whose elements are correspond to the given slice elements.

Signature:

go
func Zip2[A any, B any](a []A, b []B) []Tuple2[A, B]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip2([]int{1}, []float64{0.1})
    fmt.Println(result)

    // Output: [{1 0.1}]
}

Unzip2

Create a group of slice from a slice of Tuple2.

Signature:

go
func Unzip2[A any, B any](tuples []Tuple2[A, B]) ([]A, []B)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2 := tuple.Unzip2([]tuple.Tuple2[int, float64]{{FieldA: 1, FieldB: 0.1}})

    fmt.Printf("%v %v", v1, v2)

    // Output: [1] [0.1]
}

Tuple3

Tuple3 represents a 3 elemnets tuple.

Signature:

go
type Tuple3[A any, B any, C any] struct {
    FieldA A
    FieldB B
    FieldC C
}

func NewTuple3[A any, B any, C any](a A, b B c C) Tuple3[A, B, C]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple3(1, 0.1, "a")
    fmt.Printf("%v %v %v", t.FieldA, t.FieldB, t.FieldC)

    // Output: 1 0.1 a
}

Tuple3_Unbox

Tuple3 Unbox returns values in tuple.

Signature:

go
func (t Tuple3[A, B, C]) Unbox() (A, B, C)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple3(1, 0.1, "a")
    v1, v2, v3 := t.Unbox()
    fmt.Printf("%v %v %v", v1, v2, v3)

    // Output: 1 0.1 a
}

Zip3

Create a slice of Tuple3, whose elements are correspond to the given slice elements.

Signature:

go
func Zip3[A any, B any, C any](a []A, b []B, c []C) []Tuple3[A, B, C]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip3([]int{1}, []float64{0.1}, []string{"a"})
    fmt.Println(result)

    // Output: [{1 0.1 a}]
}

Unzip3

Create a group of slice from a slice of Tuple3.

Signature:

go
func Unzip3[A any, B any, C any](tuples []Tuple3[A, B, C]) ([]A, []B, []C)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3 := tuple.Unzip3([]tuple.Tuple3[int, float64, string]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a"},
    })

    fmt.Printf("%v %v %v", v1, v2, v3)

    // Output: [1] [0.1] [a]
}

Tuple4

Tuple4 represents a 4 elemnets tuple.

Signature:

go
type Tuple4[A any, B any, C any, D any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
}

func NewTuple4[A any, B any, C any, D any](a A, b B, c C, d D) Tuple4[A, B, C, D]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple4(1, 0.1, "a", true)
    fmt.Printf("%v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD)

    // Output: 1 0.1 a true
}

Tuple4_Unbox

Tuple4 Unbox returns values in tuple.

Signature:

go
func (t Tuple4[A, B, C, D]) Unbox() (A, B, C, D)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple4(1, 0.1, "a", true)
    v1, v2, v3, v4 := t.Unbox()
    fmt.Printf("%v %v %v %v", v1, v2, v3, v4)

    // Output: 1 0.1 a true
}

Zip4

Create a slice of Tuple4, whose elements are correspond to the given slice elements.

Signature:

go
func Zip4[A any, B any, C any, D any](a []A, b []B, c []C, d []D) []Tuple4[A, B, C, D]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip4([]int{1}, []float64{0.1}, []string{"a"}, []bool{true})
    fmt.Println(result)

    // Output: [{1 0.1 a true}]
}

Unzip4

Create a group of slice from a slice of Tuple4.

Signature:

go
func Unzip4[A any, B any, C any, D any](tuples []Tuple4[A, B, C, D]) ([]A, []B, []C, []D)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4 := tuple.Unzip4([]tuple.Tuple4[int, float64, string, bool]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true},
    })

    fmt.Printf("%v %v %v %v", v1, v2, v3, v4)

    // Output: [1] [0.1] [a] [true]
}

Tuple5

Tuple5 represents a 5 elemnets tuple.

Signature:

go
type Tuple5[A any, B any, C any, D any, E any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
}

func NewTuple5[A any, B any, C any, D any, E any](a A, b B, c C, d D, e E) Tuple5[A, B, C, D, E]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple5(1, 0.1, "a", true, 2)
    fmt.Printf("%v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE)

    // Output: 1 0.1 a true 2
}

Tuple5_Unbox

Tuple5 Unbox returns values in tuple.

Signature:

go
func (t Tuple5[A, B, C, D, E]) Unbox() (A, B, C, D, E)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple5(1, 0.1, "a", true, 2)
    v1, v2, v3, v4, v5 := t.Unbox()
    fmt.Printf("%v %v %v %v %v", v1, v2, v3, v4, v5)

    // Output: 1 0.1 a true 2
}

Zip5

Create a slice of Tuple5, whose elements are correspond to the given slice elements.

Signature:

go
func Zip5[A any, B any, C any, D any, E any](a []A, b []B, c []C, d []D, e []E) []Tuple5[A, B, C, D, E]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip5([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2}]
}

Unzip5

Create a group of slice from a slice of Tuple5.

Signature:

go
func Unzip5[A any, B any, C any, D any, E any](tuples []Tuple5[A, B, C, D, E]) ([]A, []B, []C, []D, []E)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5 := tuple.Unzip5([]tuple.Tuple5[int, float64, string, bool, int]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2},
    })

    fmt.Printf("%v %v %v %v %v", v1, v2, v3, v4, v5)

    // Output: [1] [0.1] [a] [true] [2]
}

Tuple6

Tuple6 represents a 6 elemnets tuple.

Signature:

go
type Tuple6[A any, B any, C any, D any, E any, F any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
    FieldF F
}

func NewTuple6[A any, B any, C any, D any, E any, F any](a A, b B, c C, d D, e E, f F) Tuple6[A, B, C, D, E, F]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple6(1, 0.1, "a", true, 2, 2.2)
    fmt.Printf("%v %v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE, t.FieldF)

    // Output: 1 0.1 a true 2 2.2
}

Tuple6_Unbox

Tuple6 Unbox returns values in tuple.

Signature:

go
func (t Tuple6[A, B, C, D, E, F]) Unbox() (A, B, C, D, E, F)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple6(1, 0.1, "a", true, 2, 2.2)
    v1, v2, v3, v4, v5, v6 := t.Unbox()
    fmt.Printf("%v %v %v %v %v %v", v1, v2, v3, v4, v5, v6)

    // Output: 1 0.1 a true 2 2.2
}

Zip6

Create a slice of Tuple6, whose elements are correspond to the given slice elements.

Signature:

go
func Zip6[A any, B any, C any, D any, E any, F any](a []A, b []B, c []C, d []D, e []E, f []F) []Tuple6[A, B, C, D, E, F]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip6([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2}, []float32{2.2})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2 2.2}]
}

Unzip6

Create a group of slice from a slice of Tuple6.

Signature:

go
func Unzip6[A any, B any, C any, D any, E any, F any](tuples []Tuple6[A, B, C, D, E, F]) ([]A, []B, []C, []D, []E, []F)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5, v6 := tuple.Unzip6([]tuple.Tuple6[int, float64, string, bool, int, float32]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2, FieldF: 2.2},
    })

    fmt.Printf("%v %v %v %v %v %v", v1, v2, v3, v4, v5, v6)

    // Output: [1] [0.1] [a] [true] [2] [2.2]
}

Tuple7

Tuple7 represents a 7 elemnets tuple.

Signature:

go
type Tuple7[A any, B any, C any, D any, E any, F any, G any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
    FieldF F
    FieldG G
}

func NewTuple7[A any, B any, C any, D any, E any, F any, G any](a A, b B, c C, d D, e E, f F, g G) Tuple7[A, B, C, D, E, F, G]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple7(1, 0.1, "a", true, 2, 2.2, "b")
    fmt.Printf("%v %v %v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE, t.FieldF, t.FieldG)

    // Output: 1 0.1 a true 2 2.2 b
}

Tuple7_Unbox

Tuple7 Unbox returns values in tuple.

Signature:

go
func (t Tuple7[A, B, C, D, E, F, G]) Unbox() (A, B, C, D, E, F, G)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple7(1, 0.1, "a", true, 2, 2.2, "b")
    v1, v2, v3, v4, v5, v6, v7 := t.Unbox()
    fmt.Printf("%v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7)

    // Output: 1 0.1 a true 2 2.2 b
}

Zip7

Create a slice of Tuple7, whose elements are correspond to the given slice elements.

Signature:

go
func Zip7[A any, B any, C any, D any, E any, F any, G any](a []A, b []B, c []C, d []D, e []E, f []F, g []G) []Tuple7[A, B, C, D, E, F, G]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip7([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2}, []float32{2.2}, []string{"b"})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2 2.2 b}]
}

Unzip7

Create a group of slice from a slice of Tuple7.

Signature:

go
func Unzip7[A any, B any, C any, D any, E any, F any, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5, v6, v7 := tuple.Unzip7([]tuple.Tuple7[int, float64, string, bool, int, float32, string]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2, FieldF: 2.2, FieldG: "b"},
    })

    fmt.Printf("%v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7)

    // Output: [1] [0.1] [a] [true] [2] [2.2] [b]
}

Tuple8

Tuple8 represents a 8 elemnets tuple.

Signature:

go
type Tuple8[A any, B any, C any, D any, E any, F any, G any, H any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
    FieldF F
    FieldG G
    FieldH H
}

func NewTuple8[A any, B any, C any, D any, E any, F any, G any, H any](a A, b B, c C, d D, e E, f F, g G, h H) Tuple8[A, B, C, D, E, F, G, H]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple8(1, 0.1, "a", true, 2, 2.2, "b", "c")
    fmt.Printf("%v %v %v %v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE, t.FieldF, t.FieldG, t.FieldH)

    // Output: 1 0.1 a true 2 2.2 b c
}

Tuple8_Unbox

Tuple8 Unbox returns values in tuple.

Signature:

go
func (t Tuple8[A, B, C, D, E, F, G, H]) Unbox() (A, B, C, D, E, F, G, H)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple8(1, 0.1, "a", true, 2, 2.2, "b", "c")
    v1, v2, v3, v4, v5, v6, v7, v8 := t.Unbox()
    fmt.Printf("%v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8)

    // Output: 1 0.1 a true 2 2.2 b c
}

Zip8

Create a slice of Tuple8, whose elements are correspond to the given slice elements.

Signature:

go
func Zip8[A any, B any, C any, D any, E any, F any, G any, H any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H) []Tuple8[A, B, C, D, E, F, G, H]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip8([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2}, []float32{2.2}, []string{"b"}, []string{"c"})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2 2.2 b c}]
}

Unzip8

Create a group of slice from a slice of Tuple8.

Signature:

go
func Unzip8[A any, B any, C any, D any, E any, F any, G any, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5, v6, v7, v8 := tuple.Unzip8([]tuple.Tuple8[int, float64, string, bool, int, float32, string, string]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2, FieldF: 2.2, FieldG: "b", FieldH: "c"},
    })

    fmt.Printf("%v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8)

    // Output: [1] [0.1] [a] [true] [2] [2.2] [b] [c]
}

Tuple9

Tuple9 represents a 9 elemnets tuple.

Signature:

go

type Tuple9[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
    FieldF F
    FieldG G
    FieldH H
    FieldI I
}

func NewTuple9[A any, B any, C any, D any, E any, F any, G any, H any, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I) Tuple9[A, B, C, D, E, F, G, H, I]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple9(1, 0.1, "a", true, 2, 2.2, "b", "c", map[string]int{"a": 1})
    fmt.Printf("%v %v %v %v %v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE, t.FieldF, t.FieldG, t.FieldH, t.FieldI)

    // Output: 1 0.1 a true 2 2.2 b c map[a:1]
}

Tuple9_Unbox

Tuple9 Unbox returns values in tuple.

Signature:

go
func (t Tuple9[A, B, C, D, E, F, G, H, I]) Unbox() (A, B, C, D, E, F, G, H, I)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    t := tuple.NewTuple9(1, 0.1, "a", true, 2, 2.2, "b", "c", map[string]int{"a": 1})
    v1, v2, v3, v4, v5, v6, v7, v8, v9 := t.Unbox()
    fmt.Printf("%v %v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8, v9)

    // Output: 1 0.1 a true 2 2.2 b c map[a:1]
}

Zip9

Create a slice of Tuple9, whose elements are correspond to the given slice elements.

Signature:

go
func Zip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I) []Tuple9[A, B, C, D, E, F, G, H, I]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip9([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2}, []float32{2.2}, []string{"b"}, []string{"c"}, []int64{3})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2 2.2 b c 3}]
}

Unzip9

Create a group of slice from a slice of Tuple9.

Signature:

go
func Unzip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5, v6, v7, v8, v9 := tuple.Unzip9([]tuple.Tuple9[int, float64, string, bool, int, float32, string, string, int64]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2, FieldF: 2.2, FieldG: "b", FieldH: "c", FieldI: 3},
    })

    fmt.Printf("%v %v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8, v9)

    // Output: [1] [0.1] [a] [true] [2] [2.2] [b] [c] [3]
}

Tuple10

Tuple10 represents a 10 elemnets tuple.

Signature:

go

type Tuple10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any] struct {
    FieldA A
    FieldB B
    FieldC C
    FieldD D
    FieldE E
    FieldF F
    FieldG G
    FieldH H
    FieldI I
    FieldJ J
}

func NewTuple10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](a A, b B, c C, d D, e E, f F, g G, h H, i I, j J) Tuple10[A, B, C, D, E, F, G, H, I, J]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    type foo struct {
        A string
    }
    t := tuple.NewTuple10(1, 0.1, "a", true, 2, 2.2, "b", "c", map[string]int{"a": 1}, foo{A: "a"})
    fmt.Printf("%v %v %v %v %v %v %v %v %v %v", t.FieldA, t.FieldB, t.FieldC, t.FieldD, t.FieldE, t.FieldF, t.FieldG, t.FieldH, t.FieldI, t.FieldJ)

    // Output: 1 0.1 a true 2 2.2 b c map[a:1] {a}
}

Tuple10_Unbox

Tuple10 Unbox returns values in tuple.

Signature:

go
func (t Tuple10[A, B, C, D, E, F, G, H, I, J]) Unbox() (A, B, C, D, E, F, G, H, I, J)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    type foo struct {
        A string
    }
    t := tuple.NewTuple10(1, 0.1, "a", true, 2, 2.2, "b", "c", map[string]int{"a": 1}, foo{A: "a"})
    v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 := t.Unbox()
    fmt.Printf("%v %v %v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)

    // Output: 1 0.1 a true 2 2.2 b c map[a:1] {a}
}

Zip10

Create a slice of Tuple10, whose elements are correspond to the given slice elements.

Signature:

go
func Zip10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I, j []J) []Tuple10[A, B, C, D, E, F, G, H, I, J]

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    result := tuple.Zip10([]int{1}, []float64{0.1}, []string{"a"}, []bool{true}, []int{2}, []float32{2.2}, []string{"b"}, []string{"c"}, []int64{3}, []bool{false})
    fmt.Println(result)

    // Output: [{1 0.1 a true 2 2.2 b c 3 false}]
}

Unzip10

Create a group of slice from a slice of Tuple10.

Signature:

go
func Unzip10[A any, B any, C any, D any, E any, F any, G any, H any, I any, J any](tuples []Tuple10[A, B, C, D, E, F, G, H, I, J]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I, []J)

Example:Run

go
package main

import (
    "fmt"
    "github.com/duke-git/lancet/v2/tuple"
)

func main() {
    v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 := tuple.Unzip10([]tuple.Tuple10[int, float64, string, bool, int, float32, string, string, int64, bool]{
        {FieldA: 1, FieldB: 0.1, FieldC: "a", FieldD: true, FieldE: 2, FieldF: 2.2, FieldG: "b", FieldH: "c", FieldI: 3, FieldJ: false},
    })

    fmt.Printf("%v %v %v %v %v %v %v %v %v %v", v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)

    // Output: [1] [0.1] [a] [true] [2] [2.2] [b] [c] [3] [false]
}