Swiftz Swift函数式编程

我要开发同款
匿名用户2014年06月05日
79阅读

技术信息

授权协议
BSD

作品详情

Swiftz是一个Swift库,实现了函数式编程。

示例代码:

let xs = [1, 2, 0, 3, 4]// we ca use the Mi semigroup to fid the miimal elemet i xsscocat(Mi(), 2, xs) // 0// we ca use the Sum mooid to fid the sum of xsmcocat(Sum<It8, NIt8>(i: { retur it8 }), xs) // 10// we ca delay computatios with futureslet x: Future<It> = Future(exec: gcdExecutioCotext, {  sleep(1)  retur 4})x.result() == x.result() // true, returs i 1 secod// we ca map ad flatMap over futuresx.map({ $0.descriptio }).result() // "4", returs istatlyx.flatMap({ (x: It) -> Future<It> i  retur Future(exec: gcdExecutioCotext, { sleep(1); retur x + 1 })}).result() // sleeps aother secod, the returs 5

功能介绍

Swiftz 是一个 Swift 库,实现了函数式编程。 示例代码: let xs = [1, 2, 0, 3, 4]

// we can use the Min semigroup to f...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论