In functional programming you often want to apply a function partly. A simple example is a function add.
It would be nice if we could use add like:
var res2 = add(1, 3); // => 4
var add10To = add(10);
var res = add10To(5); // => 15
| ## /robex/ - 2021 ## | |
| import matplotlib.pyplot as plt | |
| import math | |
| class Weapon: | |
| def __init__(self, rangemod, basedmg, maxrange, gainrange, name): | |
| self.rangemod = rangemod | |
| self.basedmg = basedmg | |
| self.maxrange = maxrange |
| #[derive(Debug)] | |
| enum PersonParseError { | |
| Malformed, | |
| AgeParseError(std::string::ParseError), | |
| } | |
| impl fmt::Display for PersonParseError { | |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| match *self { | |
| PersonParseError::Malformed => write!(f, "Malformed or empty input string"), |
| let _ = global._ = require("lodash"); | |
| let Benchmark = global.Benchmark = require("benchmark"); | |
| let Promise = require("bluebird"); | |
| let { Map } = require("immutable"); | |
| let { produce } = require("immer"); | |
| function getItems(count) { | |
| let id = 1; |
| import * as postcss from 'postcss'; | |
| module.exports = postcss.plugin('postcss-remove-important', (options = {}) => { | |
| return css => { | |
| css.walkDecls(decl => { | |
| decl.important = false; | |
| }); | |
| }; | |
| }); |
| // * iOS zooms on form element focus. This script prevents that behavior. | |
| // * <meta name="viewport" content="width=device-width,initial-scale=1"> | |
| // If you dynamically add a maximum-scale where no default exists, | |
| // the value persists on the page even after removed from viewport.content. | |
| // So if no maximum-scale is set, adds maximum-scale=10 on blur. | |
| // If maximum-scale is set, reuses that original value. | |
| // * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0"> | |
| // second maximum-scale declaration will take precedence. | |
| // * Will respect original maximum-scale, if set. | |
| // * Works with int or float scale values. |