26 lines
453 B
Go
26 lines
453 B
Go
package main
|
|
|
|
import "fmt"
|
|
import "sort"
|
|
|
|
func main() {
|
|
p := []int{2, 3, 13, 7, 5, 11}
|
|
fmt.Println("p ==", p)
|
|
sort.Ints(p)
|
|
fmt.Printf("%T p: %v\n", p, p)
|
|
|
|
for i := 0; i < len(p); i++ {
|
|
fmt.Printf("p[%d] == %d\n", i, p[i])
|
|
}
|
|
|
|
// slice index notation: (python)
|
|
fmt.Println("p[1:4] == ", p[1:4])
|
|
fmt.Println("p[:3] == ", p[:3])
|
|
fmt.Println("p[4:] == ", p[4:])
|
|
|
|
v := make([]string, 0)
|
|
v = append(v, "hello", "world")
|
|
fmt.Printf("%v\n", v)
|
|
|
|
}
|