/**
* 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. 自定义函数(function)

    USE [NC] GO /****** Object: UserDefinedFunction [dbo].[dict_url_channel] Script Date: 2019/5/25 16:4 ...

  2. 利用PLSQL Developer对oracle中的数据进行备份恢复

    --以备份scott用户为例,目标(备份里面所有的对象)--切换到scottconn scott/tiger;--进入  工具-->导出用户对象  如图所示 创建表空间及用户名,并赋予权限 -- ...

  3. acm java入门(转载)

    ACM中java的使用 http://www.cnblogs.com/XBWer/archive/2012/06/24/2560532.html 这里指的java速成,只限于java语法,包括输入输出 ...

  4. SpringCloud 配置文件 application.yml和 bootstrap.yml区别

    前言: SpringBoot默认支持properties和YAML两种格式的配置文件.前者格式简单,但是只支持键值对.如果需要表达列表,最好使用YAML格式.SpringBoot支持自动加载约定名称的 ...

  5. Vue学习笔记(一) 利用idea 搭建 vue 项目

    环境准备工作: 安装node.js 环境  -- 略 安装vue-li  全局安装vue-cli,在命令行中执行npm install -g vue-cli idea准备工作: 安装vue.js Fi ...

  6. 关于MySQL的索引的几件小事

    零.索引简介 1. 索引是什么 ①MySQL官方对索引的定义是:索引(Index)是帮助MySQL高效获取数据的数据结构. ②可以简单的理解为"排好序的快速查找数据结构". ③除了 ...

  7. python 访问权限

    访问权限 权限: 公有的:类中的普通属性和方法,默认都是公有的,可以在类的内部.外部.子类中使用 私有的:定义是在前面加两个'_',只能在本类的内部使用,不能再外部及子类中使用 示例: class P ...

  8. Ajax与JSON,XML,PHP

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. java反射浅谈 part1--反射机制的定义,作用,原理

    一.定义 在运行过程中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:还可以通过反射创建对象,这种动态获取的信息以及动态调用对象的方法的功能称为 ...

  10. 解决:Nginx访问静态页面出现中文乱码

    需要修改nginx的server的配置内容,增加一行:charset utf-8; 详情如下: upstream you.domainName.com { server 127.0.0.1:8080; ...