 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
Map will do a mapping from an input type into an output type.
Example ¶
package main
import (
	tsk "go.llib.dev/frameless/pkg/slicekit"
	"strconv"
	"strings"
)
func main() {
	var x = []string{"a", "b", "c"}
	_ = tsk.Must(tsk.Map[string](x, strings.ToUpper)) // []string{"A", "B", "C"}
	var ns = []string{"1", "2", "3"}
	_, err := tsk.Map[int](ns, strconv.Atoi) // []int{1, 2, 3}
	if err != nil {
		panic(err)
	}
}
func Must ¶
Example ¶
package main
import (
	"fmt"
	tsk "go.llib.dev/frameless/pkg/slicekit"
)
func main() {
	var x = []int{1, 2, 3}
	x = tsk.Must(tsk.Map[int](x, func(v int) int {
		return v * 2
	}))
	v := tsk.Must(tsk.Reduce[int](x, 42, func(output int, current int) int {
		return output + current
	}))
	fmt.Println("result:", v)
}
func Reduce ¶
Reduce iterates over a slice, combining elements using the reducer function.
Example ¶
package main
import (
	"fmt"
	tsk "go.llib.dev/frameless/pkg/slicekit"
)
func main() {
	var x = []string{"a", "b", "c"}
	got, err := tsk.Reduce[string](x, "|", func(o string, i string) string {
		return o + i
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(got) // "|abc"
}
Types ¶
This section is empty.
 Click to show internal directories. 
   Click to hide internal directories.