/*
2nd Law: Composition
'a.of((f) => (g) => (x) => f(g(x))).ap(u).ap(v).ap(w)' is equivalent to 'u.ap(v.ap(w))'
188165
function composition(f) {
    var A = f();

    return forAll(_.Int).satisfy(function(a) {
      var g = function(x) { return x * 2; };
      var h = function(x) { return x - 1; };

      function compose(f) {
        return function(g) {
          return function(x) {
            return f(g(x));
          };
        };
      }

      var x = A.of(compose).ap(A.of(g)).ap(A.of(h)).ap(A.of(a));
      var y = A.of(g).ap(A.of(h).ap(A.of(a)));

      return x.isEqual(y);
    });
  }
298099
def part(f, ii):
    '''
    
    '''
    f = to_potential(f)
    if is_const_potential(f): return PotentialConstant(f.c[ii])
    else:                     return compose(PotentialPart(ii), to_potential(f))
611124
function compose() {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return function (arg0) {
      return (0, _array.reduceRight)(function (value, fn) {
        return fn(value);
      }, arg0, args);
    };
  }
187536
function Ca (A, B, M0, M1) {
  this.A = A
  this.B = B
  this.M0 = M0
  this.M1 = M1
}
660530
public Vector2f fma(Vector2fc a, Vector2fc b, Vector2f dest) {
        dest.x = x + a.x() * b.x();
        dest.y = y + a.y() * b.y();
        return dest;
    }
72067
function(poly) { 
            //get the maximum power of each
            var mp1 = this.coeffs.length-1, 
                mp2 = poly.coeffs.length-1,
                T;
            //swap so we always have the greater power first
            if(mp1 < mp2) {
                return poly.gcd(this);
            }
            var a = this;

            while(!poly.isZero()) {   
                var t = poly.clone(); 
                a = a.clone(); 
                T = a.divide(t);
                poly = T[1]; 
                a = t; 
            }

            var gcd = core.Math2.QGCD.apply(null, a.coeffs);
            if(!gcd.equals(1)) { 
                var l = a.coeffs.length;
                for(var i=0; i<l; i++) {
                    a.coeffs[i] = a.coeffs[i].divide(gcd);
                }
            }
            return a;
        }
1058652
function ceil(out, a) {
  out[0] = Math.ceil(a[0]);
  out[1] = Math.ceil(a[1]);
  out[2] = Math.ceil(a[2]);
  return out;
}
428585
function isequal(a, b, tolerance) {
    if (tolerance === void 0) { tolerance = constants_1.EPSILON; }
    return iszero(a - b, tolerance);
}
313003
def compose(*funcs):
    
    # slightly optimized for most common cases and hence verbose
    if len(funcs) == 2: f0,f1=funcs; return lambda *a,**kw: f0(f1(*a,**kw))
    elif len(funcs) == 3: f0,f1,f2=funcs; return lambda *a,**kw: f0(f1(f2(*a,**kw)))
    elif len(funcs) == 0: return lambda x:x     # XXX single kwarg
    elif len(funcs) == 1: return funcs[0]
    else:
        def composed(*args,**kwargs):
            y = funcs[-1](*args,**kwargs)
            for f in funcs[:0:-1]: y = f(y)
            return y
        return composed
1003021
function(symbol1, symbol2) {
            var result, remainder, factored, den;
            factored = core.Algebra.Factor.factor(symbol1.clone());
            den = factored.getDenom();
            if(!den.isConstant('all')) {
                symbol1 = _.expand(Symbol.unwrapPARENS(_.multiply(factored, den.clone())));
            }
            else
                //reset the denominator since we're not dividing by it anymore
                den = new Symbol(1); 
            result = __.div(symbol1, symbol2);
            remainder = _.divide(result[1], symbol2);
            return _.divide(_.add(result[0], remainder), den);
        }
856907
def compose_functions(*func_list):
    
    def apply_composition(f, g):
        def compose(x):
            return f(g(x))
        return compose
    composed_func = functools.reduce(apply_composition, func_list)
    return composed_func
1176487
function equals(a, b) {
  var a0 = a[0]
  var a1 = a[1]
  var b0 = b[0]
  var b1 = b[1]
  return (Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
          Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)))
}
715143
public static <A, B> Predicate<A> compose(Predicate<B> predicate, Function<A, ? extends B> function) {
		return t -> predicate.test(function.apply(t));
	}
664885
def compose(*parameter_functions):
  
  def composed_fn(var_name, variable, phase):
    for fn in parameter_functions:
      variable = fn(var_name, variable, phase)
    return variable
  return composed_fn
215068
function ifElse(pred, f, g) {
  if(!isPredOrFunc(pred)) {
    throw new TypeError(
      'ifElse: Pred or predicate function required for first argument'
    )
  }

  if(!(isFunction(f) && isFunction(g))) {
    throw new TypeError(
      'ifElse: Functions required for second and third arguments'
    )
  }

  return x => predOrFunc(pred, x) ? f(x) : g(x)
}
427982
public static <A, B> Predicate<A> compose(
      Predicate<B> predicate, Function<A, ? extends B> function) {
    return new CompositionPredicate<A, B>(predicate, function);
  }
1008607
function(d2) {

      var w = this['w'];
      var x = this['x'];
      var y = this['y'];
      var z = this['z'];

      var n = w * w + x * x + y * y + z * z;
      var s = n === 0 ? 0 : 2 / n;
      var wx = s * w * x, wy = s * w * y, wz = s * w * z;
      var xx = s * x * x, xy = s * x * y, xz = s * x * z;
      var yy = s * y * y, yz = s * y * z, zz = s * z * z;

      if (d2) {
        return [
          [1 - (yy + zz), xy - wz, xz + wy],
          [xy + wz, 1 - (xx + zz), yz - wx],
          [xz - wy, yz + wx, 1 - (xx + yy)]];
      }

      return [
        1 - (yy + zz), xy - wz, xz + wy,
        xy + wz, 1 - (xx + zz), yz - wx,
        xz - wy, yz + wx, 1 - (xx + yy)];
    }