Skip to content

PHPで組み込み関数やユーザー定義関数のカリー化や部分適用を支援するライブラリ

License

Notifications You must be signed in to change notification settings

shin-sakata/lambda-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-php

Build Status codecov StyleCI Maintainability MIT License

About

関数志向をサポートするライブラリ

<?php

use Chemirea\Lambda\Lambda as L;

$add = function (int $x, int $y): int {
    return $x + $y;
};

$wrappedAdd = L::wrap($add);

// この様に普通に呼び出せる
$wrappedAdd(1,2); // 3

// この様にカリー化されている
$wrappedAdd(1)(2); // 3

// 上と同じ
$addOne = $wrappedAdd(1);
$addOne(2); // 3


$addTwo = $wrappedAdd(2);

// この様に関数合成をして$addOneの返り値を,
// そのままaddTwoの引数として取る様な関数として定義することができる
$addOneTwo = $addOne->bind($addTwo);

$addOneTwo(1); // 4

install

$ composer require chemirea/lambda-php=dev-master

About

PHPで組み込み関数やユーザー定義関数のカリー化や部分適用を支援するライブラリ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages