const curry =  R.curry((fns, ary) => R.ap(fns, ary));
const applyMultiAndAdd = curry([R.multiply(), R.add()]);
const res = applyMultiAndAdd([,,]); console.log(res); //[2, 4, 6, 4, 5, 6] const compose = R.compose(
R.reverse,
R.ap([R.multiply(), R.add()])
);
const res1 = compose([,,]);
console.log(res1); //[6, 5, 4, 6, 4, 2] const addOne = R.curry( (x) => R.add(, x))
const pipe = R.pipe(
R.ap([R.multiply(), R.add()]),
R.reverse,
R.map(addOne)
); const res2 = pipe([,,]);
console.log(res2); //[7, 6, 5, 7, 5, 3]

[Ramda] Curry, Compose and Pipe examples的更多相关文章

  1. 函数式编程-compose与pipe

    函数式编程中有一种模式是通过组合多个函数的功能来实现一个组合函数.一般支持函数式编程的工具库都实现了这种模式,这种模式一般被称作compose与pipe.以函数式著称的Ramda工具库为例. cons ...

  2. [Ramda] Curry and Uncurry Functions with Ramda

    Most of the functions offered by the ramda library are curried by default. Functions you've created ...

  3. [Ramda] Refactor to Point Free Functions with Ramda using compose and converge

    In this lesson we'll take some existing code and refactor it using some functions from the Ramda lib ...

  4. [JS Compose] 6. Semigroup examples

    Let's we want to combine two account accidently have the same name. , friends: ['Franklin'] } , frie ...

  5. [Functional Programming] Compose Simple State ADT Transitions into One Complex Transaction

    State is a lazy datatype and as such we can combine many simple transitions into one very complex on ...

  6. js函数式编程(三)-compose和pointFree

    compose即函数嵌套组合 组合compose在第一篇已经初见端倪,可以感受一下.compose函数的实现用闭包的方法.不完善实现如下: const compose = (f, g) => { ...

  7. 每个JavaScript开发人员应该知道的33个概念

    每个JavaScript开发人员应该知道的33个概念 介绍 创建此存储库的目的是帮助开发人员在JavaScript中掌握他们的概念.这不是一项要求,而是未来研究的指南.它基于Stephen Curti ...

  8. [Javascript] Functor Basic Intro

    Well, this stuff will be a little bit strange if you deal with it first time. Container Object: Just ...

  9. [Functional Programming] From simple implementation to Currying to Partial Application

    Let's say we want to write a most simple implementation 'avg' function: const avg = list => { let ...

随机推荐

  1. android组件

    SlidingDrawer http://www.cnblogs.com/renyuan/archive/2012/09/16/2687929.html autocompletetextview  / ...

  2. AJAX - 封装的传参改为传入对象 XML JSON 数据格式

    Ajax封装函数,上次是直接传参,这次在原来的基础上改进,模仿jQuery 直接传入对象,把之前的参数都变为这个对象的属性. 这样可以随意调换传入数据的次序. 其他优点? 需要再复习一下. Ajax处 ...

  3. C#之使用app.config可记录数据,下次打开可读取记录的数据

    一.背景 如下图所示,我通过open..按键打开了某个文件,之后我再把app给关闭掉,当再次打开app的时候,在textBox.Text上显示上一次打开的文件路径.通过使用app.config可以保存 ...

  4. PatentTips - Interrupt redirection for virtual partitioning

    BACKGROUND The present disclosure relates to the handling of interrupts in a environment that utiliz ...

  5. STM32W108无线射频模块串行通信接口编程实例

    STM32W108无线射频模块UART通信应用实例 基于STM32W108芯片,编写串口測试程序,測试串口通信.完毕PC通过串口与STM32W108进行通信. 开发环境与硬件平台 硬件:STM32W1 ...

  6. libcurl 通过http协议下载文件并显示下载进度

    vc6 测试工程下载地址:http://download.csdn.net/detail/mtour/8068053 代码如下: size_t my_write_func(void *ptr, siz ...

  7. ORA-16014 ORA-00312

    打开alert日志发现如下错误信息 Errors in file /oracle/app/oracle/admin/hncdfhq/bdump/hncdfhq_arc0_45285882.trc: O ...

  8. OC中对于属性的总结(@property)

    在没有属性之前: 对成员变量进行改动都要用到设置器:setter来改动 Person *per =[[Person alloc] init]; 对象通过设置器对成员变量内容进行修该 [per setN ...

  9. 策略模式 VS 桥梁模式

    这对冤家终于碰头了,策略模式与桥梁模式是如此相似,简直就是孪生兄弟,要把它们两个分开需要花费大量智力,我们来看看两者的通用类图,如图33-1所示. 图33-1 策略模式(左)和桥梁模式(右)通用类图 ...

  10. 【习题 3-9 UVA - 10340】All in All

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 相当于让你判断s1是不是s2的子序列. for一遍就好 [代码] #include <bits/stdc++.h> us ...