Documentation
¶
Index ¶
- func Concat[A any, LA ~[]A, LLA ~[]LA](xss LLA) []A
- func Conform[A any, CA Class[A]](c CA) func(t *testing.T, x, y, z List[A])
- func FoldR[A, B any, LA ~[]A](f func(A, B) B, z B, xs LA) B
- func Intercalate[A any, LA ~[]A, LLA ~[]LA](xs LA, xss LLA) []A
- func Intersperse[A any, LA ~[]A](v A, xs LA) []A
- func Map[A, B any, LA ~[]A](fn func(A) B, xs LA) []B
- func NewEqualFn[A any, LA ~[]A](e eq.Class[A]) func(x, y LA) bool
- func NonEmptySubsequences[A any, LA ~[]A](la LA) [][]A
- func Reverse[A any, LA ~[]A](xs LA) []A
- func Subsequences[A any, LA ~[]A](xs LA) [][]A
- func Transpose[A any, LA ~[]A, LLA ~[]LA](xss LLA) [][]A
- type Class
- type List
- type T
- type Type
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Conform ¶ added in v0.0.4
Conform returns a function testing if the implementation abides by its laws.
func Intercalate ¶ added in v0.0.9
func Intercalate[A any, LA ~[]A, LLA ~[]LA](xs LA, xss LLA) []A
Example (Arraybyte) ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(string(list.Intercalate(
[]byte(", "),
[][]byte{
[]byte("Lorem"),
[]byte("ipsum"),
[]byte("dolor"),
},
)))
}
Output: Lorem, ipsum, dolor
Example (Listbyte) ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(string(list.Intercalate(
list.List[byte](", "),
list.List[list.List[byte]]{
list.List[byte]("Lorem"),
list.List[byte]("ipsum"),
list.List[byte]("dolor"),
},
)))
}
Output: Lorem, ipsum, dolor
func Intersperse ¶ added in v0.0.9
func Intersperse[A any, LA ~[]A](v A, xs LA) []A
Example ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(string(list.Intersperse(',', list.List[byte]("abcde"))))
}
Output: a,b,c,d,e
func Map ¶ added in v0.0.9
func Map[A, B any, LA ~[]A](fn func(A) B, xs LA) []B
Example ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(
list.Map(
func(x int) int {
return x + 1
},
list.List[int]{1, 2, 3},
),
)
}
Output: [2 3 4]
func NewEqualFn ¶ added in v0.0.5
NewEqualFn returns a list equality checking function given the eq.Class for the type A.
func NonEmptySubsequences ¶ added in v0.0.9
func NonEmptySubsequences[A any, LA ~[]A](la LA) [][]A
Example ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(list.NonEmptySubsequences([]int{1, 2, 3}))
}
Output: [[1] [2] [1 2] [3] [1 3] [2 3] [1 2 3]]
func Reverse ¶ added in v0.0.9
func Reverse[A any, LA ~[]A](xs LA) []A
Example ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(list.Reverse(list.List[int]{}))
fmt.Println(list.Reverse(list.List[int]{42}))
fmt.Println(list.Reverse(list.List[int]{2, 5, 7}))
}
Output: [] [42] [7 5 2]
func Subsequences ¶ added in v0.0.9
func Subsequences[A any, LA ~[]A](xs LA) [][]A
Example ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(list.Subsequences([]int{1, 2, 3}))
}
Output: [[] [1] [2] [1 2] [3] [1 3] [2 3] [1 2 3]]
func Transpose ¶ added in v0.0.9
func Transpose[A any, LA ~[]A, LLA ~[]LA](xss LLA) [][]A
Example (Equal) ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(list.Transpose([][]int{{1, 2, 3}, {4, 5, 6}}))
}
Output: [[1 4] [2 5] [3 6]]
Example (Mixed) ¶
package main
import (
"fmt"
"github.com/calebcase/base/data/list"
)
func main() {
fmt.Println(list.Transpose([][]int{{10, 11}, {20}, {}, {30, 31, 32}}))
}
Output: [[10 20 30] [11 31] [32]]
Types ¶
Click to show internal directories.
Click to hide internal directories.