Original post

https://play.golang.org/p/Cx0dV30P5PZ

package main

import "fmt"

// returns the min element of the array
func minArr(a []int) int {
        if len(a) == 1 {
                return a[0]
        }

        if a[0] > a[1] {
                return minArr(a[1:])
        } else {
                return minArr(append(a[:1], a[2:]...))
        }
}

func main() {
        a := []int{1, 2, 44, 0}
        m := minArr(a)
        fmt.Printf("a: %v, min: %v", a, m)
}

why does minArr mutate the slice?