<commit_before>package tricks_test

import (
	"fmt"
	"strings"

	"github.com/aviddiviner/tricks"
)

var animals = []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

func ExampleSlice() {
	bearCow := tricks.Slice(animals).
		Map(strings.ToUpper).
		Last(5).
		First(2).
		Value().([]string)

	fmt.Println(bearCow)

	// Output: [BEAR COW]
}

func ExampleSlice_groupBy() {
	byLength := tricks.Slice(animals).
		Copy().Sort().
		GroupBy(func(s string) int { return len(s) }).
		Value().(map[int][]string)

	fmt.Println(byLength[3])

	// Output: [cat cow dog pig]
}

func ExampleSlice_strings() {
	password := tricks.Slice([]rune("ab<PASSWORD>")).Reverse().Value().([]rune)
	fmt.Println(string(password))

	// Output: arbadacarba
}

// TODO: Add variadic example.<commit_msg>Tweak examples to look better<commit_after>package tricks_test

import (
	"fmt"
	"strings"

	"github.com/aviddiviner/tricks"
)

func ExampleSlice() {
	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

	bearCow := tricks.Slice(animals).
		Map(strings.ToUpper).
		Last(5).
		First(2).
		Value().([]string)

	fmt.Println(bearCow)
	// Output: [BEAR COW]
}

func ExampleSlice_strings() {
	password := tricks.Slice([]rune("<PASSWORD>")).Reverse().Value().([]rune)
	fmt.Println(string(password))
	// Output: arbadacarba
}

// TODO: Add variadic example.

func ExampleTrickSlice_GroupBy() {
	animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"}

	byLength := tricks.Slice(animals).
		Copy().
		Sort().
		Reverse().
		GroupBy(func(s string) int { return len(s) }).
		Value().(map[int][]string)

	fmt.Println(byLength[3])
	// Output: [pig dog cow cat]
}
{'fraction_non_alphanumeric': 0.2069377990430622, 'fraction_numerical': 0.0035885167464114833, 'mean_word_length': 4.503289473684211, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6047209', 'n_tokens_mistral': 668, 'n_tokens_neox': 633, 'n_words': 122}