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.
This commit is contained in:
Dan Buch
2012-12-21 22:49:50 -05:00
parent 209e074503
commit 5d5ada2dfc
5 changed files with 98 additions and 8 deletions

View File

@@ -0,0 +1,34 @@
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
}