承接 phrenotype/lambda 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

phrenotype/lambda

最新稳定版本:v1.5.0

Composer 安装命令:

composer require phrenotype/lambda

包简介

Converts php functions to lambdas

README 文档

README

github stars license contributors code size

This is a library for converting both named and annonymous php functions into lambda expressions. This the allows them to be curried and partially applied.

Install

composer require phrenotype/lambda

Examples

With all parameters required

$add = lambda(function($a, $b, $c){
	return $a + $b + $c;
});

echo $add(4,5,2);
echo $add(4,5)(2);
echo $add(4)(5,2);
echo $add(4)(5)(2);

With optional parameters

This is a little bit tricky.

$add = lambda(function($a, $b, $c=2){
	return $a + $b + $c;
});

The key thing to remember is that once the numbers of arguments applied exactly matches the required number of arguments, It will return a result, not a lambda. So, in applying arguments, do not apply them curry style when dealing with optional parameters. Use partial application instead.

echo $add(4,5,2); // Ok
echo $add(4)(5,2) // Ok
echo $add(4,5)(2); // Error
echo $add(4)(5)(2); //Error

Contact

Email : paul.contrib@gmail.com

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-17