λ Functional
Functional programming treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is declarative, which means expressions instead of statements.
Siler is bundled with the Siler\Functional
namespace. It brings some function declarations that aids the work with another first-class and high-order PHP functions!
identity()
identity()
Returns a Closure that returns its given arguments.
always($value)
always($value)
Almost like identity()
, but it always returns the given value.
if_else(callable $cond) -> $then -> $else
if_else(callable $cond) -> $then -> $else
A functional if/then/else.
partial(callable $callable, ...$partial)
partial(callable $callable, ...$partial)
Nothing like a good example:
Works with any callable
:
match(array $matches)
match(array $matches)
A pattern-match attempt. Truthy Closure evaluations on the left calls and short-circuits evaluations on the right.
Last updated
Was this helpful?