<commit_before>package generic

import (
	"fmt"
)

func ExampleSum() {
	in := []int{1, 2, 3, 4}
	out := Sum(in).(int)
	fmt.Println(out)
	// Output: 10
}

func ExampleSum_slice() {
	in := [][]int{[]int{1, 2}, []int{3, 4}}
	out := Sum(in).([]int)
	fmt.Println(out)
	// Output: [1 2 3 4]
}

func ExampleFilter_even() {
	in := []int{1, 2, 3, 4}
	out := Filter(in, func(a int) bool { return a%2 == 0 }).([]int)
	fmt.Println(out)
	// Output: [2 4]
}

func ExampleMap_square() {
	in := []int{1, 2, 3, 4}
	out := Map(in, func(a int) int { return a * a }).([]int)
	fmt.Println(out)
	// Output: [1 4 9 16]
}

func ExampleMap_add_float() {
	in := []int{1, 2, 3, 4}
	out := Map(in, func(a int) float64 { return float64(a) + 0.1 }).([]float64)
	fmt.Println(out)
	// Output: [1.1 2.1 3.1 4.1]
}

func ExampleMap_extract_type() {
	in := []interface{}{1, 2, 3, 4}
	out := Map(in, func(a interface{}) int { return a.(int) }).([]int)
	fmt.Println(out)
	// Output: [1 2 3 4]
}

func ExampleReduce_sum() {
	in := []int{1, 2, 3, 4}
	out := Reduce(in, 0, func(a, b int) int { return a + b }).(int)
	fmt.Println(out)
	// Output: 10
}

func ExampleReduce_mult() {
	in := []float64{-1, 3, 4}
	out := Reduce(in, 1, func(a, b float64) float64 { return a * b }).(float64)
	fmt.Println(out)
	// Output: -12
}

func ExampleReduce_concat() {
	in := []string{"a", "b", "c"}
	out := Reduce(in, "", func(a, b string) string { return a + b }).(string)
	fmt.Println(out)
	// Output: abc
}
<commit_msg>Make the examples import the package<commit_after>package generic_test

import (
	"fmt"
	"gnd.la/util/generic"
)

func ExampleSum() {
	in := []int{1, 2, 3, 4}
	out := generic.Sum(in).(int)
	fmt.Println(out)
	// Output: 10
}

func ExampleSum_slice() {
	in := [][]int{[]int{1, 2}, []int{3, 4}}
	out := generic.Sum(in).([]int)
	fmt.Println(out)
	// Output: [1 2 3 4]
}

func ExampleFilter_even() {
	in := []int{1, 2, 3, 4}
	out := generic.Filter(in, func(a int) bool { return a%2 == 0 }).([]int)
	fmt.Println(out)
	// Output: [2 4]
}

func ExampleMap_square() {
	in := []int{1, 2, 3, 4}
	out := generic.Map(in, func(a int) int { return a * a }).([]int)
	fmt.Println(out)
	// Output: [1 4 9 16]
}

func ExampleMap_add_float() {
	in := []int{1, 2, 3, 4}
	out := generic.Map(in, func(a int) float64 { return float64(a) + 0.1 }).([]float64)
	fmt.Println(out)
	// Output: [1.1 2.1 3.1 4.1]
}

func ExampleMap_extract_type() {
	in := []interface{}{1, 2, 3, 4}
	out := generic.Map(in, func(a interface{}) int { return a.(int) }).([]int)
	fmt.Println(out)
	// Output: [1 2 3 4]
}

func ExampleReduce_sum() {
	in := []int{1, 2, 3, 4}
	out := generic.Reduce(in, 0, func(a, b int) int { return a + b }).(int)
	fmt.Println(out)
	// Output: 10
}

func ExampleReduce_mult() {
	in := []float64{-1, 3, 4}
	out := generic.Reduce(in, 1, func(a, b float64) float64 { return a * b }).(float64)
	fmt.Println(out)
	// Output: -12
}

func ExampleReduce_concat() {
	in := []string{"a", "b", "c"}
	out := generic.Reduce(in, "", func(a, b string) string { return a + b }).(string)
	fmt.Println(out)
	// Output: abc
}

{'fraction_non_alphanumeric': 0.22862757943006878, 'fraction_numerical': 0.05240746806419915, 'mean_word_length': 3.5177514792899407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6620477', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1329, 'n_words': 358}