library functional-array
A functional wrapper for arrays
park-brian/functional-array
A functional wrapper for arrays
- Friday, September 29, 2017
- by park-brian
- Repository
- 1 Watchers
- 0 Stars
- 5 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 0 % Grown
LazyArray
, (*1)
Lazily-evaluated PHP arrays, (*2)
Requirements
Getting Started
composer require park-brian/functional-array
Usage
<?php
use FunctionalArray\FunctionalArray as FnArray;
$sum = FnArray::create(range(1, 10))
->map (function($value) { return $value * 2; })
->filter (function($value) { return $value > 10; })
->reduce (function($acc = 0, $value) { return $acc + $value; });
echo $sum;
$fruitRatings = [
'apples' => 70,
'bananas' => 80,
'cherries' => 90,
'dragonfruit' => 100
];
$favoriteFruits = FnArray::create($fruitRatings)
->filter (function($value) { return $value >= 80; })
->map (function($value, $key) { return "Rating for $key: $value"; })
->reduce (function($acc, $value) { return " $acc \n $value"; })
echo $favoriteFruits;
dev-master
9999999-dev
A functional wrapper for arrays
Sources
Download
MIT
The Requires
The Development Requires
0.0.2
0.0.2.0
A functional wrapper for arrays
Sources
Download
MIT
The Requires
The Development Requires
0.0.1
0.0.1.0
A functional wrapper for arrays
Sources
Download
MIT
The Requires
The Development Requires