/*
********************************************************************
/* Compose methods, scalars, number
********************************************************************
557804
public CollectionComposer<PARENT,C> add(int value)
    {
        _collection.add(Integer.valueOf(value));
        return this;
    }
1306919
function compose(auto_template, dictionary, key, params) {
    var composer = dictionary[key];

    // If auto_template is set to true, make dictionary value
    if (auto_template) {
        if (typeof composer === "string") {
            composer = _.template(composer);
        } else if (typeof composer !== "function" ) {
            var msg = 'Expected value to auto-template - "' + composer + '" - to be type "string"';
            msg += ' but got "' + typeof composer + '".';
            throw new Error(msg);
        }
    }

    switch (typeof composer) {
        case "string": return composer;
        case "function": return composer(params);
        default:
            {
                var msg = 'Unprocessable message "' + composer + '" of type "' + typeof composer;
                msg += '" for key "' + key + '".'
                throw new Error(msg);
            }
    }
}
463140
function composition(f) {
    return forAll(_.Int).satisfy(function(a) {
      function g(x) { return x * 2; }
      function h(x) { return x - 1; }

      function returnComposition(b) {
        return g(h(b));
      }

      return f(a).map(returnComposition).isEqual(f(a).map(h).map(g));
    });
  }
127538
function scalar(schema, defaults, options) {
  if (kindOf(schema) !== 'string') {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Scalar structs must be defined as a string, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  const { types } = options
  const fn = types[schema]

  if (kindOf(fn) !== 'function') {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `No struct validator function found for type "${schema}".`
      )
    } else {
      throw new Error(`Invalid type: ${schema}`)
    }
  }

  const kind = func(fn, defaults, options)
  const name = 'scalar'
  const type = schema
  const validate = value => {
    const [error, result] = kind.validate(value)

    if (error) {
      error.type = type
      return [error]
    }

    return [undefined, result]
  }

  return new Kind(name, type, validate)
}
1097676
func (sf *ScalarFunction) String() string {
	var buffer bytes.Buffer
	fmt.Fprintf(&buffer, "%s(", sf.FuncName.L)
	for i, arg := range sf.GetArgs() {
		buffer.WriteString(arg.String())
		if i+1 != len(sf.GetArgs()) {
			buffer.WriteString(", ")
		}
	}
	buffer.WriteString(")")
	return buffer.String()
}
519879
function sl__processRelativeTime(number, withoutSuffix, key, isFuture) {
        var result = number + ' ';
        switch (key) {
        case 's':
            return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
        case 'm':
            return withoutSuffix ? 'ena minuta' : 'eno minuto';
        case 'mm':
            if (number === 1) {
                result += withoutSuffix ? 'minuta' : 'minuto';
            } else if (number === 2) {
                result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
            } else if (number < 5) {
                result += withoutSuffix || isFuture ? 'minute' : 'minutami';
            } else {
                result += withoutSuffix || isFuture ? 'minut' : 'minutami';
            }
            return result;
        case 'h':
            return withoutSuffix ? 'ena ura' : 'eno uro';
        case 'hh':
            if (number === 1) {
                result += withoutSuffix ? 'ura' : 'uro';
            } else if (number === 2) {
                result += withoutSuffix || isFuture ? 'uri' : 'urama';
            } else if (number < 5) {
                result += withoutSuffix || isFuture ? 'ure' : 'urami';
            } else {
                result += withoutSuffix || isFuture ? 'ur' : 'urami';
            }
            return result;
        case 'd':
            return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
        case 'dd':
            if (number === 1) {
                result += withoutSuffix || isFuture ? 'dan' : 'dnem';
            } else if (number === 2) {
                result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
            } else {
                result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
            }
            return result;
        case 'M':
            return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
        case 'MM':
            if (number === 1) {
                result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
            } else if (number === 2) {
                result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
            } else if (number < 5) {
                result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
            } else {
                result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
            }
            return result;
        case 'y':
            return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
        case 'yy':
            if (number === 1) {
                result += withoutSuffix || isFuture ? 'leto' : 'letom';
            } else if (number === 2) {
                result += withoutSuffix || isFuture ? 'leti' : 'letoma';
            } else if (number < 5) {
                result += withoutSuffix || isFuture ? 'leta' : 'leti';
            } else {
                result += withoutSuffix || isFuture ? 'let' : 'leti';
            }
            return result;
        }
    }
134142
private void addParams(TypeSpec.Builder parent, LocaleID id, NumberData data) {
    MethodSpec.Builder code = MethodSpec.constructorBuilder();
    code.addStatement("this.decimal = $S", data.decimal);
    code.addStatement("this.group = $S", data.group);
    code.addStatement("this.percent = $S", data.percent);
    code.addStatement("this.minus = $S", data.minus);
    code.addStatement("this.plus = $S", data.plus);
    code.addStatement("this.exponential = $S", data.exponential);
    code.addStatement("this.superscriptingExponent = $S", data.superscriptingExponent);
    code.addStatement("this.perMille = $S", data.perMille);
    code.addStatement("this.infinity = $S", data.infinity);
    code.addStatement("this.nan = $S", data.nan);
    code.addStatement("this.currencyDecimal = $S", data.currencyDecimal);
    code.addStatement("this.currencyGroup = $S", data.currencyGroup);

    TypeSpec.Builder params = TypeSpec.classBuilder("_Params")
        .superclass(NumberFormatterParams.class)
        .addModifiers(PRIVATE, STATIC)
        .addMethod(code.build());

    parent.addType(params.build());
  }
946001
function paddingNumber(num, radix, digits, upperCase, paddingChar, sign, align) {
  let str = num.toString(radix);
  if (upperCase) {
    str = str.toUpperCase();
  }
  if (digits === 0) {
    return str;
  }

  if (sign === "plus" && num >= 0) {
    str = `+${str}`;
  } else if (sign === "space" && num >= 0) {
    str = ` ${str}`;
  }

  let len = str.length;
  let result = "";
  while ((digits - len++) > 0) {
    result += paddingChar;
  }

  if (align === "left") {
    result = str + result;
  } else {
    result += str;
  }

  if (align === "right_lead_sign") {
    result = result.replace(/.(.*)([-+ ])(.+)/i, `$2$1${paddingChar}$3`);
  }

  return result;
}
345357
function compose () {
  // the function required by the server
  function middlewareF (req, res, end) {
    var index = 0

    // inject stats middleware
    if (middlewareF.options && middlewareF.options.stats) {
      middlewareF.stack = middlewareF.stack.map(function (mw) {
        var fn
        if (typeof mw === 'object') {
          var key = Object.keys(mw)[0]
          if (!mw[key].stats) {
            fn = {}
            fn[key] = middlewareF.options.stats(mw[key])
          }
        } else {
          if (!mw.stats) {
            fn = middlewareF.options.stats(mw)
          }
        }
        return fn
      })
    }

    // looping over all middleware functions defined by stack
    ;(function next (err) {
      var arity
      var middleware = middlewareF.stack[index++] // obtain the current middleware from the stack

      if (!middleware) {
        // we are at the end of the stack
        end && end(err)
        return
      } else {
        // extract middleware from object
        if (typeof (middleware) === 'object') {
          var name = Object.keys(middleware)[0]
          if (typeof (middleware[name]) === 'function') {
            middleware = middleware[name]
          } else {
            middleware = function (req, res, next) {
              next(new Error('missing middleware'))
            }
          }
        }

        try {
          arity = middleware.length // number of arguments function middleware requires
          // handle errors
          if (err) {
            // If the middleware function contains 4 arguments than this will act as an "error trap"
            if (arity === 4) {
              middleware(err, req, res, function (err) {
                nextTick(next, err)
              })
            } else {
              // otherwise check the next middleware
              next(err)
            }
          } else if (arity < 4) {
            // process non "error trap" stack
            middleware(req, res, function (err) {
              nextTick(next, err)
            })
          } else {
            // loop over "error traps" if no error `err` is set.
            next()
          }
        } catch (e) {
          next(e)
        }
      }
    })()
  }

  middlewareF.stack = []
  middlewareF.options = compose.options || {}

  ;[].slice.call(arguments).forEach(function (a) {
    middlewareF.stack = middlewareF.stack.concat(compose.decompose(a))
  })

  // extends
  ;[ 'before', 'after', 'replace', 'remove', 'push', 'unshift', 'clone' ].forEach(function (p) {
    middlewareF[p] = compose[p]
  })

  // inject stats middleware
  if (compose.options.stats) {
    middlewareF.options = {}
    middlewareF.options.stats = compose.options.stats
  }

  return middlewareF
}
571907
function compose(key, compositor, traits) {
		return Fn.compose(this.prototype, key, compositor, traits);
	}
262861
function compose () {
        var fns = arguments;

        return function () {
            var result = void 0;

            for (var i = fns.length - 1; i > -1; i--) {
                if (i === fns.length - 1) {
                    result = fns[i].apply(fns[i], arguments);
                } else {
                    result = fns[i].call(this, result);
                }
            }

            return result;
        };
    }
962727
function compileString($string) {
        /**
         * Examples:
         *  numeric[-10, 30)
         *  integer(0, inf)
         *  float[0,1]
         */
        $numeric = '/^(numeric|float|integer|int)((\(|\[).+,[^\]\)]+(\)|\]))$/';
        /**
         * Examples:
         *  string{pendent, payed, ready, cancelled}
         *  integer{10, 100, 1000}
         *  scalar{0, false}
         *  {0, false} //same as the previous one
         */
        $valueSetScalar = '/^(scalar|string|float|integer|int|str|boolean|bool|numeric)?(\{[^}]*\})$/';

        /**
         * Examples:
         *  string(5..10)
         *  string(5..)
         *  string(..10)
         *  string(5..5) // strict length
         *  string(..) // pointless, but valid
         */
        $lengthString = '/^string(\(\d*\.\.\d*\))$/';

        /**
         * Examples:
         *  (string|integer)[]
         *  (string|integer{0,1})[]
         *  (bool{true}|integer[1,inf))[]
         */
        $quickArray = "/^(\\(.+(\\|.+)+\\)|[^\\|]*)\\[(\\d+|\\d*\\+|\\*|\\d*\\.\\.\\d*)?\\]$/";

        $identityStructure = array(
            "check" => function($data, $null, &$failed) { return true; },
            "format" => function($data) { return $data; }
        );

        // allow "type1|type2|..."
        $types = explode("|", $string);

        if (preg_match($quickArray, $string)) {
            $structure = new ArrayS();
            $structure->setFormat($string);
            $structure->setCountStrict($this->countStrict);
            $arrayStructure = true;

            $objects = array($structure);
            $i = count($types) + 1;
        } else {
            /** @var Structure[] $objects */
            $objects = array();

            // Use a do-while to check always $type[0]
            $i = 0;
        }
        while (count($types) > $i) {
            $type = $types[$i];
            if (preg_match($numeric, $type, $matches)) {
                switch ($type[0]) {
                    case "n": $structure = new NumericS(); break;
                    case "f": $structure = new FloatS(); break;
                    case "i": $structure = new IntegerS(); break;
                }
                /** @var NumericS $structure */
                $structure->setRange($matches[2]);
            } else if (preg_match($valueSetScalar, $type, $matches)) {
                switch ($type[0] . $type[1]) {
                    default: //fall through to _scalar_
                    case "sc": $structure = new ScalarS(); break;
                    case "st": $structure = new StringS(); break;
                    case "nu": $structure = new NumericS(); break;
                    case "fl": $structure = new FloatS(); break;
                    case "in": $structure = new IntegerS(); break;
                    case "bo": $structure = new BooleanS(); break;
                }
                /** @var ScalarS $structure */
                $structure->setValueSet($matches[2]);
            } else if (preg_match($lengthString, $type, $matches)) {
                $structure = new StringS();
                $structure->setLength($matches[1]);
            } else if (preg_match($quickArray, $type, $matches)) {
                $structure = new ArrayS();
                $structure->setFormat($type);
                $structure->setCountStrict($this->countStrict);
                $arrayStructure = true;
            } else {
                switch ($type) {
                    case "scalar": $structure = new ScalarS(); break;
                    case "string":// fall through to _str_
                    case "str": $structure = new StringS(); break;
                    case "numeric": $structure = new NumericS(); break;
                    case "integer":// fall through to _int_
                    case "int": $structure = new IntegerS(); break;
                    case "float": $structure = new FloatS(); break;
                    case "boolean":// fall through to _bool_
                    case "bool": $structure = new BooleanS(); break;
                    case "array":
                        $structure = new ArrayS();
                        $structure->setFormat("array");
                        $structure->setCountStrict($this->countStrict);
                        break;
                    case "*":
                    case "any":
                        // set structure:identity
                        $structure = $identityStructure;
                        break;
                    case "null":
                    case null:
                        // set structure:null
                        $structure = array(
                            "check" => function($data, $null, &$failed) {
                                $valid = is_null($data);
                                if (!$valid) $failed = Structure::typeof($data);
                                return $valid;
                            },
                            "format" => function() { return null; }
                        );
                        break;
                    default:
                        if (class_exists($string)) {
                            // todo: create ObjectS class
                            $structure = array(
                                "check" => function($data, $null, &$failed) use ($string) {
                                    if (is_null($data)) $valid = $null;
                                    else $valid = $data instanceof $string;

                                    if (!$valid) $failed = Structure::typeof($data);
                                    return $valid;
                                },
                                "format" => $identityStructure["format"]
                            );
                        } else {
                            // maybe $format is a simple array (type[] or type[int])
                            $structure = new ArrayS();
                            $structure->setFormat($type);
                            $structure->setCountStrict($this->countStrict);
                            $arrayStructure = true;
                        }
                        break;
                }
                //prevent errors
                if (!isset($structure)) {
                    $structure = $identityStructure;
                }
            }

            // Add the Structure to use it after the loop
            $objects[] = $structure;
            $i++;
        }

        /**
         * Define return functions, depending on the number of $objects
         * (1 or more)
         */
        $ret = array();
        if ($i == 1) {
            if ($objects[0] instanceof Structure) {
                $check = function ($data, $null, &$failed) use ($objects) {
                    $objects[0]->setNull($null);
                    return $objects[0]->check($data, $failed);
                };
                $format = function ($data, $null) use ($objects) {
                    $objects[0]->setNull($null);
                    return $objects[0]->format($data);
                };
            } else {
                $check = $objects[0]["check"];
                $format = function ($data) use ($objects) {
                    return call_user_func($objects[0]["format"], $data);
                };
            }
        } else {
            $check = function($data, $null, &$failed) use ($objects) {
                foreach ($objects as $obj) {
                    if ($obj instanceof Structure) {
                        $obj->setNull($null);
                        if ($obj->check($data, $failed)) return true;
                    } else if (is_array($obj) && isset($obj["check"])) {
                        $check = $obj["check"];
                        if ($check($data, $null, $failed)) return true;
                    }
                }
                return false;
            };
            $format = function($data, $null) use ($objects) {
                foreach ($objects as $obj) {
                    try {
                        if ($obj instanceof Structure) {
                            $obj->setNull($null);
                            return $obj->format($data);
                        } else {
                            return call_user_func($obj["format"], $data);
                        }
                    } catch (\Exception $e) {}
                }
                throw new \Exception("Unable to format \$data");
            };
        }
        $ret["check"] = $check;
        $ret["format"] = $format;

        if (isset($arrayStructure) && $arrayStructure) {
            $ret["meta"] = "array";
        }

        return $ret;
    }
109558
function(vec2, returnNew) {
      var x,y;
      if ('number' !== typeof vec2) {
        x = vec2.x;
        y = vec2.y;

      // Handle incoming scalars
      } else {
        x = y = vec2;
      }

      if (x === 0 || y === 0) {
        throw new Error('division by zero')
      }

      if (isNaN(x) || isNaN(y)) {
        throw new Error('NaN detected');
      }

      if (returnNew) {
        return new Vec2(this.x / x, this.y / y);
      }

      return this.set(this.x / x, this.y / y);
    }
319143
function describe(composer, trailing) {

  return function (method) {

    return new Descriptor(function (key, previousValues) {

      if ( method !== undefined)
        previousValues[trailing ? 'push' : 'unshift' ](method)

      //console.log(previousValues)
      return reduce(previousValues, function(merged, next, idx){
        return trailing
          ? composer(next, merged)
          : composer(merged, next)
      })
    })
  }
}
531171
function BigNumber(number) {
    this.numberStr = number.toString();

    // not a number
    if (isNaN(parseFloat(this.numberStr)) === true
        || isFinite(this.numberStr) === false) {
        throw new Error(number + ' is not a number');
    }
}
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
62069
function composeObject (src, srcKey, dest, destKey, transform) {
            if (_.isUndefined(src)) {
                return;
            }
            var value = src[srcKey];
            if (_.isUndefined(value)) {
                return;
            }
            if (_.isArray(value) && _.isEmpty(value)) {
                return;
            }
            
            if (_.isObject(value) && _.isEmpty(value)) {
                return;
            }
            
            if (transform) {
                value = transform(value);
            }
            
            dest[destKey || srcKey] = value;
        }