camspiers/php-fp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

camspiers/php-fp

Composer 安装命令:

composer require camspiers/php-fp

包简介

Functional Programming Helpers

README 文档

README

Currying

A curryable function returns a new function when called with less arguments than the curryable function requires. The new function returned will have the arguments applied, and will also be a curryable function.

This programming pattern can be used to build up more complex functions from less complex functions.

e.g.

// Create a curryable function
$concat = fp\curry(function ($a, $b) { return $a . $b; });

// Create a new function with 'Mr. ' applied
$addTitle = $concat('Mr. ');

echo $addTitle('Spiers');
// Mr. Spiers

Composition

$h = fp\compose($f, $g);

Function composition will return a new function ($h) which will first apply the second function ($g), pass its result into the first ($f).

Usage

Turning normal functions into curryable functions

$map = fp\curry('array_map');

Create non-closure functions that are curryable

function _tag($tag, $text) {
    return "<$tag>$text</$tag>";
}

function tag(...$args) {
    return fp\curry('_tag')->__invoke(...$args);
}

// We now have a paragraph function
$p = tag('p');

// We now have a div function
$div = tag('div');

echo $div($p("Some text"));
// <div><p>Some text</p></div>

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固