Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

floats: add Reverse function #47

Merged
merged 1 commit into from
Mar 15, 2016
Merged

floats: add Reverse function #47

merged 1 commit into from
Mar 15, 2016

Conversation

kortschak
Copy link
Member

@btracey Please take a look. We may as well.

Fixes #26.

@@ -590,6 +590,13 @@ func Prod(s []float64) float64 {
return prod
}

// Reverse reverses the order of elements in the slice.
func Reverse(s []float64) {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not mine. This was one of the early examples in Miek Gieben's Learning Go book which was the first book I read (I think possibly the first book on Go).

@btracey
Copy link
Member

btracey commented Mar 15, 2016

LGTM with the extra tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants