From fae9dcf298dac97f18aa6dcebe211e33b10fd6be Mon Sep 17 00:00:00 2001 From: btracey Date: Thu, 16 May 2013 14:58:23 -0700 Subject: [PATCH] Switched receiver and slice order in cumsum and added check for nil receiver --- sliceops.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sliceops.go b/sliceops.go index 52d51ff4..d1720f94 100644 --- a/sliceops.go +++ b/sliceops.go @@ -61,7 +61,10 @@ func Prod(s []float64) (prod float64) { // Finds the cumulative sum of the first i elements in // s and puts them in place into the ith element of the // receiver. If the receiver is nil a new slice is created -func CumSum(s, receiver []float64) []float64 { +func CumSum(receiver, s []float64) []float64 { + if receiver == nil { + receiver = make([]float64, len(s)) + } if len(s) == 0 { return receiver[:0] }