john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

curry

<!DOCTYPE html><html><head><title></title></head><body><pre><script>


    function add( a , b ) {
        return a + b;
    }
    function mul( a , b ) {
        return a * b;
    }


    function curry( func, first ){

        return function ( second ) {
                    return func( first , second);
                };
    }



    var add3 = curry( add, 3 );
    document.writeln( add3(4) );               // 7
    document.writeln( curry( mul(5)(6) );               // 7

//    document.writeln( applyf(mul)(5)(6) )  // 30


</script></pre></body></html>

  • « applyf
  • increment with functional programming »

Published

Oct 5, 2013

Category

javascript

~43 words

Tags

  • curry 1
  • javascript 43