This commit is contained in:
John O'Keefe 2023-10-24 20:36:25 -04:00
parent 9fe6dcac42
commit 9d9ddfedcd
2 changed files with 44 additions and 0 deletions

View File

@ -32,6 +32,8 @@ func main() {
averageMySolution()
case "Get the Average Head First Solution":
averageHeadFirstSolution()
case "Slices":
slices()
}
return nil
})
@ -46,6 +48,7 @@ func main() {
menu.Option("Convert To Celsius", nil, false, nil)
menu.Option("Get the Average My Solution", nil, false, nil)
menu.Option("Get the Average Head First Solution", nil, false, nil)
menu.Option("Slices", nil, false, nil)
err := menu.Run()
if err != nil {
log.Fatal(err)

41
slices.go Normal file
View File

@ -0,0 +1,41 @@
package main
import "fmt"
func slices() {
var notes []string
notes = make([]string, 7)
notes[0] = "do"
notes[1] = "re"
notes[2] = "mi"
fmt.Println(notes[0])
fmt.Println(notes[1])
fmt.Println(len(notes))
primes := make([]int, 5)
primes[0] = 2
primes[1] = 3
primes[2] = 5
primes[3] = 7
primes[4] = 11
fmt.Println(primes[0])
fmt.Println(primes[1])
fmt.Println(primes[2])
fmt.Println(primes[3])
fmt.Println(primes[4])
fmt.Println(len(primes))
literalNotes := []string{"do", "re", "mi", "fa", "so", "la", "ti"}
fmt.Println(literalNotes[3], literalNotes[6], literalNotes[0])
literalPrimes := []int{
2,
3,
5,
}
fmt.Println(literalPrimes[0], literalPrimes[1], literalPrimes[2])
fmt.Println(literalPrimes, len(literalPrimes))
literalPrimes = append(literalPrimes, 7, 11)
fmt.Println(literalPrimes, len(literalPrimes))
}