/**
* When
*/ const _branch = (x) => {
const result = (x && x.isPublic) ?
dissoc('private', x) : x; console.log(result);
return assoc('result', 'done', result);
} const handlePublic = when(
propEq('isPublic', true),
dissoc('private')
);
const assignDone = assoc('result', 'done');
const branch = compose(
assignDone,
handlePublic
); /**Unless */
const _isDefaultArray = (x) => {
const result = !isArray(x) ?
[] :
x; return result.map(wrap => ({wrap}))
} const isDefaultArray = compose(
map(objOf('wrap')),
unless(
isArray,
constant([])
)
) log(
isDefaultArray([10,11,12,13])
)

[Functional Programming] Examples: When and Unless的更多相关文章

  1. BETTER SUPPORT FOR FUNCTIONAL PROGRAMMING IN ANGULAR 2

    In this blog post I will talk about the changes coming in Angular 2 that will improve its support fo ...

  2. Beginning Scala study note(4) Functional Programming in Scala

    1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...

  3. Functional Programming without Lambda - Part 2 Lifting, Functor, Monad

    Lifting Now, let's review map from another perspective. map :: (T -> R) -> [T] -> [R] accep ...

  4. Functional Programming without Lambda - Part 1 Functional Composition

    Functions in Java Prior to the introduction of Lambda Expressions feature in version 8, Java had lon ...

  5. a primary example for Functional programming in javascript

    background In pursuit of a real-world application, let’s say we need an e-commerce web applicationfo ...

  6. Functional programming

    In computer science, functional programming is a programming paradigm, a style of building the struc ...

  7. Java 中的函数式编程(Functional Programming):Lambda 初识

    Java 8 发布带来的一个主要特性就是对函数式编程的支持. 而 Lambda 表达式就是一个新的并且很重要的一个概念. 它提供了一个简单并且很简洁的编码方式. 首先从几个简单的 Lambda 表达式 ...

  8. Functional programming idiom

    A functional programming function is like a mathematical function, which produces an output that typ ...

  9. 关于函数式编程(Functional Programming)

    初学函数式编程,相信很多程序员兄弟们对于这个名字熟悉又陌生.函数,对于程序员来说并不陌生,编程对于程序员来说也并不陌生,但是函数式编程语言(Functional Programming languag ...

随机推荐

  1. pb SendMessage

    PB发送和接收消息send SendMessage 1.用PB自带的SEND函数发送消息 传字符:Send(Handle(w_main),1600,0,'dfdfd') 传LONG:Send(Hand ...

  2. iview给布局MenuItem标签绑定点击事件

    @click.native="menuHandleClick"

  3. python自带queue

    from queue import Queue # 线程安全队列 def thread_queue(): q = Queue(3) # 这个队列最多进多少东西 q.put('a') q.put('b' ...

  4. Glide优化

    几乎所有的 OOM 错误都是因为宿主应用出了问题,而不是 Glide 本身. 应用里两种常见的 OOM 错误分别是: 过大的内存分配 (Excessively large allocations) 内 ...

  5. MVC4中去掉浏览器生成的无关代码方法

    通过增加Web.Config配置,如: <add key="vs:EnableBrowserLink" value="false"/>可以去掉MVC ...

  6. 动画方案 Lottie 学习(一)之基础

    参考 lottie系列文章(一):lottie介绍 lottie系列文章(二):lottie最佳实践 lottie系列文章(三):动画设计规范 lottie系列文章(四):源码分析——svg渲染

  7. python之项目依赖管理

    生成所有依赖清单 requirements.txt 1.  pipreqs 工具 安装) pip install pipreqs 执行生成依赖列表命令) pipreqs ./ 完善版本: pipreq ...

  8. Sublime Text 3:自定义语法高亮

    (http://ilkinulas.github.io/programming/2016/02/05/sublime-text-syntax-highlighting.html) 要安装"P ...

  9. centos7常见问题(更新。。。)

    1.网络设置 装好CentOS7后,我们一开始是上不了网的 DHCP 这时候,可以输入命令dhclient,可以自动获取一个IP地址,再用命令ip addr查看IP 不过这时候获取的IP是动态的,下次 ...

  10. Java注解【三、注解的分类】

    按运行机制分 源码注解 只在源码中存在 编译时注解 在class中依然存在,如@Deprecated 运行时注解 运行阶段起作用,如@Autowired 按来源分 JDK自带注解 三方注解 最常见 自 ...