mvaload / php-pairs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-pairs

Build Status Code Climate Issue Count

Functions for working with Pairs

use function Pairs\cons;
use function Pairs\car;
use function Pairs\cdr;
use function Pairs\toString;

Functions for working with Lists

use function Lists\length;
use function Lists\reverse;
use function Lists\map;
use function Lists\filter;
use function Lists\reduce;

Examples

$pair = cons(1, 2);

$one = Pairs\car($pair); // $one = 1;
$two = Pairs\cdr($pair) // $two = 2;

$list = cons(1, cons(2, cons(3, cons(4, cons(5, cons(6, null))))));
$length = length($list); // $length = 6;

$filter = filter(function ($x) {
    return $x % 2 == 0;
}, $list);
$result = toString($filter); \\ $result = "(2, 4, 6)";

About


Languages

Language:PHP 97.6%Language:Makefile 2.4%