Skip to content

Instantly share code, notes, and snippets.

@blubberdiblub
Last active September 18, 2018 06:55
Show Gist options
  • Save blubberdiblub/bb142618f18c013c3af53b869d5ae479 to your computer and use it in GitHub Desktop.
Save blubberdiblub/bb142618f18c013c3af53b869d5ae479 to your computer and use it in GitHub Desktop.
linear sweep variant #4
private static void sweepLinear(double min, double max, int num_intervals) {
for (int i = 0; i <= num_intervals; i++) {
int j = num_intervals - i;
double value = (max * i + min * j) / num_intervals;
doSomethingWithValue(value);
}
}
/* Output:
1.5
2.0
2.5
1.5
1.6
1.7
1.8
1.9
2.0
2.1
2.2
2.3
2.4
2.5
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment