PHP code example of andres-ml / fpl

1. Go to this page and download the library: Download andres-ml/fpl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andres-ml / fpl example snippets


use function Aml\Fpl\{compose, partial};
use const Aml\Fpl\{last};

$lastWord = compose(last, partial('explode', ' '));
$lastWord('some words in a sentence'); // 'sentence'

use Aml\Fpl;

$lastWord = Fpl\compose(Fpl\last, Fpl\partial('explode', ' '));
$lastWord('some words in a sentence'); // 'sentence'

use function Aml\Fpl\{compose, partial, last};

// note that we use 'last()' instead of just 'last'
$lastWord = compose(last(), partial('explode', ' '));
$lastWord('some words in a sentence'); // 'sentence'

use function Aml\Fpl\functions\{map};

use Aml\Fpl;

$lowerThan4 = function($x) { return $x < 4; };

Fpl\takeWhile($lowerThan4, [0, 1, 2, 3, 4, 5]); // [0, 1, 2, 3]

$pickLowerThan4 = Fpl\compose(
    Fpl\toArray
    Fpl\takeWhile($lowerThan4),
    Fpl\counter
);

$pickLowerThan4(); // [0, 1, 2, 3]