Files
box-o-sand/algs4/src/go/algs4-test-accumulator/main.go
Dan Buch 5d5ada2dfc Filling in Accumulator implementation and test client
as well as fixing the Canvas implementation so that it doesn't pop up an
X window on init.
2012-12-21 22:49:50 -05:00

35 lines
474 B
Go

package main
import (
"errors"
"fmt"
"os"
"strconv"
"github.com/meatballhat/box-o-sand/algs4/src/go/algs4"
)
func die(err error) {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
}
func main() {
if len(os.Args) < 2 {
die(errors.New("We need an int!"))
}
nValues, err := strconv.Atoi(os.Args[1])
if err != nil {
die(err)
}
a := algs4.NewAccumulator()
for t := 0; t < nValues; t++ {
a.AddDataValue(algs4.Random())
}
fmt.Println(a)
return
}