rem: var f3 = list.partial(1,2, _, _); 
add: var f3 = list.partial(1,2,_,_); 
context: function examples() {    // create an unspecialized function that just lists its (four) arguments    function list(a,b,c,d) {return [a,b,c,d]};    // specialize the first and third parameters    var f2 = list.partial(1,_,2,_);    trace('f2 3 ->', f2(3, 4));    // specialize the first two parameters (same as currying)    var f3 = list.partial(1,2, _, _);    trace('f3 4, 5 -> ', f3(4,5));        // if not all the parameters are supplied, the result is a function...    trace(f2(4));    // ...which can be applied until the function is saturated.    trace('f2 4, 5 ->', f2(3)(4));    trace(f3(_,3)(4));    trace(f3(3)(4));    trace(list.partial(_, _, _, 1)(2, _, 3)(4));    // create some specialized versions of String replace    var replaceVowels = "".replace.partial(/[aeiou]/g, _);    var replaceWithCoronalFricatives = "".replace.partial(_, 'th');    // have to invoke methods with call() (could use bind() and then call normally)    trace(replaceVowels.call("change my vowels to underscores", '_'));    trace(replaceWithCoronalFricatives.call("substitute my esses with tee-aitches", /s/g));    // use right curry to create 'halve' and 'double' functions out of divide    function divide(a, b) {return a/b}    var halve = divide.rcurry(2);    var double = divide.rcurry(1/2);    trace('halve 10', halve(10));    trace('double 10', double(10));        // curries are like Haskell sections    // (10 /) 2    trace(divide.curry(10)(2));    // (/ 2) 10    trace(divide.rcurry(2)(10));    // while partials are like math function syntax    // (10 / _) 2    trace(divide.partial(10, _)(2));    // (_ / 2) 10    trace(divide.partial(_, 2)(10));        // ncurry and rncurry wait until they're fully saturated before    // applying the function.  [r]curry can't because it doesn't    // know the polyadicity of the underlying function.    trace(list.curry(1,2)(3));    trace(list.ncurry(4,1,2)(3));    trace(list.ncurry(4,1,2)(3)(4));    trace(list.ncurry(4,1,2)(3,4));    trace(list.rncurry(4,1,2)(3));    trace(list.rncurry(4,1,2)(3,4));        // Use with Prototype to define an 'onclick' that abbreviates    // Event.observe(_, 'click', ...)    var onclick = Event.observe.bind(Event).partial(_, 'click');    Event.observe('e1', 'click', function(){alert('1')});    onclick('e2', function(){alert('2')});    onclick('e3', alert.bind(null).only('3'));        // pluck and reverse    trace(pluck('length')("a string"));    trace(invoke('reverse')([1,2,3,4]));        // compose() and sequence() compose sequences of functions    // backwards and forwards, respectively    function prepender(prefix) {return ''.concat.bind(prefix)}    trace(prepender('im')('possible'));    trace(compose(prepender('hemi'), prepender('demi'))('quaver'));    trace(sequence(prepender('hemi'), prepender('demi'))('quaver'));    // this uses map() from Prototype    trace(compose.apply(null, ['hemi', 'demi', 'semi'].map(prepender))('quaver'));}
meta: 10840	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/10840/7a8372a5868c6c38d02f197d98a9ae2972985a47/partials-demo.js/clean/partials-demo.js