fixdom random errors and bugs
This commit is contained in:
parent
56fa94fce7
commit
f68fdf3d9b
@ -3,7 +3,7 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func sum(numbers ...int) int {
|
||||
var sum int = 0
|
||||
var sum = 0
|
||||
|
||||
for _, number := range numbers {
|
||||
sum += number
|
||||
|
@ -14,7 +14,7 @@ func averageCalc(numbers ...float64) float64 {
|
||||
return sum / float64(len(numbers))
|
||||
}
|
||||
|
||||
func averageHeadFirstVariadic() {
|
||||
func main() {
|
||||
arguments := os.Args[1:]
|
||||
var numbers []float64
|
||||
for _, argument := range arguments {
|
||||
@ -22,5 +22,5 @@ func averageHeadFirstVariadic() {
|
||||
Error(err)
|
||||
numbers = append(numbers, number)
|
||||
}
|
||||
fmt.Printf("Average: %0.2\n", averageCalc(numbers...))
|
||||
fmt.Printf("Average: %0.2f\n", averageCalc(numbers...))
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
)
|
||||
|
||||
func maximum(numbers ...float64) float64 {
|
||||
max := math.Inf(-1)
|
||||
maxNumber := math.Inf(-1)
|
||||
for _, number := range numbers {
|
||||
if number > max {
|
||||
max = number
|
||||
if number > maxNumber {
|
||||
maxNumber = number
|
||||
}
|
||||
}
|
||||
return max
|
||||
return maxNumber
|
||||
}
|
||||
|
||||
func inRange(min float64, max float64, numbers ...float64) []float64 {
|
||||
|
@ -15,7 +15,10 @@ func OpenFile(fileName string) (*os.File, error) {
|
||||
|
||||
func CloseFile(file *os.File) {
|
||||
fmt.Println("Closing file")
|
||||
file.Close()
|
||||
err := file.Close()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func GetFloats(fileName string) ([]float64, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user