Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 523 Bytes

partial.md

File metadata and controls

36 lines (25 loc) · 523 Bytes

partial

Description

Fix a number of arguments to a function producing another one with an smaller arity. If not arguments are present, it returns the same $fn

Parameters

fn
Function to be biased.
args
Arguments to fix to the function.

Examples

Add 5 to another number:

<?php

use function Lambdish\Phunctional\partial;

$sum = function($a, $b) {
    return $a + $b;
};

$add5 = partial($sum, 5);

$add5(10);
// => 15

$add5(3);
// => 8