SwiftzSwift函数式编程
Swiftz 是一个 Swift 库,实现了函数式编程。
示例代码:
let xs = [1, 2, 0, 3, 4] // we can use the Min semigroup to find the minimal element in xs sconcat(Min(), 2, xs) // 0 // we can use the Sum monoid to find the sum of xs mconcat(Sum<Int8, NInt8>(i: { return nint8 }), xs) // 10 // we can delay computations with futures let x: Future<Int> = Future(exec: gcdExecutionContext, { sleep(1) return 4 }) x.result() == x.result() // true, returns in 1 second // we can map and flatMap over futures x.map({ $0.description }).result() // "4", returns instantly x.flatMap({ (x: Int) -> Future<Int> in return Future(exec: gcdExecutionContext, { sleep(1); return x + 1 }) }).result() // sleeps another second, then returns 5
评论
浅析函数式编程
函数式编程 1. 函数 高中一年级,应该是最早接触函数这个概念的时间,印象很深刻,毕竟是高考压轴大题,但它却是必修一第二章的内容。 我们来看一个必修一中最简单的一个函数: 上面的函数由三个部分组成: x 自变量...
MakerStack
0
《函数式编程指南》
《函数式编程指南》是使用JavaScript进行函数式编程的书籍,告诉大家如何在日常工作中更好的利用函数式编程的特性。Part1Chapter1:Whateverarewedoing?Introduc
《函数式编程指南》
0
F#函数式编程语言
F#是由微软发展的为微软.NET语言提供运行环境的程序设计语言,是函数编程语言(FP,FunctionalProgramming),函数编程语言最重要的基础是LambdaCalculus。它是基于OC
F#函数式编程语言
0
ToolzPython 函数式编程工具箱
Toolz是Python的函数式编程工具箱。Toolz支持Python2.6+和Python3.3+。Toolz的实现包括三部分:itertoolz,foroperationsoniterables.
ToolzPython 函数式编程工具箱
0