package main

import (
	"fmt"
	"slices"
)

func main() {
	// section: example
	animals := []string{
		"snake",
		"guinea pig",
		"elephant",
		"deer",
		"snake",
		"dung beetle",
		"okapi",
		"badger",
		"lovebird",
		"coyote",
		"camel",
		"antelope",
		"marten",
		"rabbit",
		"cougar",
		"cow",
		"finch",
		"snake",
		"reindeer",
		"rat",
		"moose",
		"crocodile",
		"snake",
		"giraffe",
		"gnu",
	}
	fmt.Printf("Original Slice:\nlen: %d, \ncap: %d, \nelements: %v\n", len(animals), cap(animals), animals)

	i := slices.Index(animals, "snake")
	for i > -1 {
		animals = slices.Replace(animals, i, i+1, "gopher")
		i = slices.Index(animals, "snake")
	}

	slices.Sort(animals)

	animals = slices.Compact(animals)

	animals = slices.Clip(animals)

	fmt.Printf("Final Slice:\nlen: %d, \ncap: %d, \nelements: %v\n", len(animals), cap(animals), animals)
	// section: example
}
