code: function bimap(domain, range, interpolate) {
    var d0 = domain[0], d1 = domain[1], r0 = range[0], r1 = range[1];
    if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
    else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
    return function(x) { return r0(d0(x)); };
  }
docs: normalize(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1]. interpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding range value x in [a,b].