/**
* 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. [转帖]如何在Linux上使用命令行查看硬件信息

    如何在Linux上使用命令行查看硬件信息 时间:2016-01-13   作者:admin 分类:新手入门 阅读:126次 http://embeddedlinux.org.cn/emb-linux/ ...

  2. 批量删除redis的数据

    批量删除redis的数据 # redis-cli -h 192.168.1.17 -p 6379 keys "xiaolang_*"|xargs redis-cli -h 192. ...

  3. 小菜鸟之Phyhon

    # print("输入成绩",end="") # src=input() # print("成绩",end=src)#成绩 # print( ...

  4. SQLYOG如何将数据导出excel格式

    方法/步骤     如图,笔者的数据库中有一张student表,想把这张表中的数据导出成excel   在这张表上右击,选择“Export”,再选择“Export Table Data as CSV, ...

  5. Linux就该这么学——初识管道符

    初识管道命令符 管道命令符本质(就是一个“任意门”) 把前一个命令原本要输出到屏幕的标准正常数据当做是最后一个命令的标准输入 格式 : “命令A | 命令B | ...” 示例 : 1.找出被限制登录 ...

  6. mysql-tpcc测试

    os: centos 7.4 db: mysql 5.7 software: tpcc-mysql TPC-C是专门针对联机交易处理系统(OLTP系统)的规范. tpcc-mysql是percona基 ...

  7. [C#.net]xlApp.Workbooks.Open打开无法远程访问

    上月还能使用的xlApp.Workbooks.Open,这个月报无法远程访问,搞了半天,才找到原因是Foxit PDF 的Execl插件搞的鬼,记录下 Excel.Workbooks wbChecks ...

  8. HttpWorkerRequest应用简介

    1. Using HttpWorkerRequest for getting headers1.使用HttpWorkerRequest获取headers信息 First, the HttpWorker ...

  9. JS基础_if练习一

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...

  10. java基础4(线程)

    1.请简单描述什么是并行,什么是并发? 并行:指两个或多个事件在同一时刻发生(同时发生). 并发:指两个或多个事件在同一个时间段内发生. 通俗易懂版: 你吃饭吃到一半,电话来了,你一直到吃完了以后才去 ...