view doodle/core/misc.d @ 139:e33f37b14893 default tip

Port to 'no-more-make' https://github.com/GrahamStJack/no-more-make
author David Bryant <bagnose@gmail.com>
date Sun, 30 Sep 2012 15:41:25 +0930
parents 15ca7d5cd1ed
children
line wrap: on
line source

module doodle.core.misc;

// Basic routines.
// Note, most of these are probably provided by phobos.

double min(in double a, in double b) {
    return a < b ? a : b;
}

double max(in double a, in double b) {
    return a > b ? a : b;
}

double clamp(in double v, in double min, in double max) {
    assert(min < max);

    if (v < min) { return min; }
    else if (v > max) { return max; }
    else { return v; }
}

// wrap?