Stated · filter.ce
The program accepts an integer sequence named input.
The program accepts an integer named threshold.
The program computes the following result.
Collect the input values in encounter order into a fresh sequence.
Retain each value only when it is greater than the threshold.
Replace each retained value with the doubled value of that value
before appending it.
Generated Go · abridged
result := make([]int64, 0)
for _, value := range input {
if value > threshold {
doubled, ok := checkedAdd(value, value)
if !ok {
return nil, overflowDiagnostic()
}
result = append(result, doubled)
}
}
return result, nil