Part1-curry


  • 0
    administrators

    按照注释改写代码,代码引入了一个支持性质的依赖文件 support.js,源码可见 github,还有已经引入了 Ramda.js。

    参考答案在讨论区。


  • 0
    administrators

    本题答案:

    // Exercise 1
    //==============
    // Refactor to remove all arguments by partially applying the function
    
    var _ = R
    
    var words = _.split(' ')
    
    // Exercise 1a
    //==============
    // Use map to make a new words fn that works on an array of strings.
    
    var sentences = _.map(words);
    
    
    // Exercise 2
    //==============
    // Refactor to remove all arguments by partially applying the functions
    
    var filterQs = _.filter(match(/q/i));
    
    
    // Exercise 3
    //==============
    // Use the helper function _keepHighest to refactor max to not reference any arguments
    
    // LEAVE BE:
    var _keepHighest = function(x,y){ return x >= y ? x : y; };
    
    // REFACTOR THIS ONE:
    var max = _.reduce(_keepHighest, -Infinity)
    
    

  • 0

    ???我代码和这个一模一样为啥过不了测试


  • 0

    @Mondo 。。。。。。。。match 不能用 Ramda 的


登录后回复
 

与 ScriptOJ 的连接断开,我们正在尝试重连,请耐心等待