Renamed inputs
Stated names the function and its inputs in natural language. This example uses vocabulary specific to its domain while keeping the same filtering and transformation operations.
Stated source
Define select-and-double-values as a function.It accepts an integer sequence named supplied-values, an integer named upper-bound, and another integer named lower-bound.Collect the supplied-values values in encounter order into a fresh sequence. Retain each value only when it is greater than the upper-bound and it is greater than the lower-bound. Replace each retained value with the doubled value of that value before appending it.Generated Go
go
package generated
import (
"errors"
"math"
)
func SelectAndDoubleValues(p0 []int64, p1 int64, p2 int64) ([]int64, error) {
result := make([]int64, 0)
for _, value := range p0 {
if value > p1 && value > p2 {
if value > math.MaxInt64/2 || value < math.MinInt64/2 {
return nil, errors.New("integer overflow")
}
result = append(result, value+value)
}
}
return result, nil
}