PHP Класс QCheck\FP

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
args ( ) : callable Returns a function that simply return that arguments it receives.
assoc ( array $arr, $k, $val ) : array Return a copy of the given array where the value at index $k has been changed to $val.
comp ( callable $f, callable $g ) : callable Compose the two functions
concat ( ) : Generator Lazily iterate over all iterable collection given as parameters in order.
cycle ( callable $f ) : Generator Iterate infinitely on the result of the given callable.
excludeNth ( integer $n, array $xs ) : array Return a copy of the array with the Nth element removed.
filter ( callable $f, $coll ) : Generator Filter the given iterable collection using the callback in a lazy way.
iterator ( $xs ) : ArrayIterator Return an iterator for the given collection if possible.
map ( callable $f, Iterator $coll ) : Generator Map a function to an iterable collection in a lazy way using generators
method ( ) : callable Return a function that calls the given method (first parameter) on any given object with the given arguments (remaining parameters).
partial ( ) : callable Return a callable with all the given arguments already bound to the function (first parameter).
partition ( integer $n, $coll ) : Generator Return the given collection partitioned in n sized segments in a lazy fashion.
property ( string $name ) : callable Return a function that returns the given property on any given object.
push ( array $xs, $x ) : array Return a copy of the given array with the given value added at the end.
range ( integer $min, integer $max ) : Generator Produce a range starting at $min and finishing with $max.
realize ( array | Iterator $it ) : array Transform the given iterable collection to a "real" array.
reduce ( callable $f, $xs, null $initial = null ) : mixed | null Reduce any iterable collection using the callback. In case of an array, array_reduce is used.
repeat ( integer $n, mixed $val ) : Generator repeat the value n times in a lazy fashion.
rgen ( Generator $xs ) : RewindableIterator Return an Iterator allowing a rewind on the given generator.
str ( array $chars ) : string Create a string with the given char array.
take ( integer $n, Iterator $it ) : Generator Return at most $n elements from the given iterable collection in a lazy fashion.
takeNth ( integer $n, $coll ) : Generator Return every Nth elements in the given collection in a lazy fashion.

Описание методов

args() публичный статический Метод

Returns a function that simply return that arguments it receives.
public static args ( ) : callable
Результат callable

assoc() публичный статический Метод

Return a copy of the given array where the value at index $k has been changed to $val.
public static assoc ( array $arr, $k, $val ) : array
$arr array
$k
$val
Результат array

comp() публичный статический Метод

Compose the two functions
public static comp ( callable $f, callable $g ) : callable
$f callable
$g callable
Результат callable

concat() публичный статический Метод

Lazily iterate over all iterable collection given as parameters in order.
public static concat ( ) : Generator
Результат Generator

cycle() публичный статический Метод

Iterate infinitely on the result of the given callable.
public static cycle ( callable $f ) : Generator
$f callable
Результат Generator

excludeNth() публичный статический Метод

Return a copy of the array with the Nth element removed.
public static excludeNth ( integer $n, array $xs ) : array
$n integer
$xs array
Результат array

filter() публичный статический Метод

Filter the given iterable collection using the callback in a lazy way.
public static filter ( callable $f, $coll ) : Generator
$f callable
$coll
Результат Generator

iterator() публичный статический Метод

Return an iterator for the given collection if possible.
public static iterator ( $xs ) : ArrayIterator
$xs
Результат ArrayIterator

map() публичный статический Метод

Map a function to an iterable collection in a lazy way using generators
public static map ( callable $f, Iterator $coll ) : Generator
$f callable
$coll Iterator
Результат Generator

method() публичный статический Метод

Return a function that calls the given method (first parameter) on any given object with the given arguments (remaining parameters).
public static method ( ) : callable
Результат callable

partial() публичный статический Метод

Return a callable with all the given arguments already bound to the function (first parameter).
public static partial ( ) : callable
Результат callable

partition() публичный статический Метод

Return the given collection partitioned in n sized segments in a lazy fashion.
public static partition ( integer $n, $coll ) : Generator
$n integer
$coll
Результат Generator

property() публичный статический Метод

Return a function that returns the given property on any given object.
public static property ( string $name ) : callable
$name string
Результат callable

push() публичный статический Метод

Return a copy of the given array with the given value added at the end.
public static push ( array $xs, $x ) : array
$xs array
$x
Результат array

range() публичный статический Метод

If $max is negative, the range will be infinite.
public static range ( integer $min, integer $max ) : Generator
$min integer
$max integer
Результат Generator

realize() публичный статический Метод

Transform the given iterable collection to a "real" array.
public static realize ( array | Iterator $it ) : array
$it array | Iterator
Результат array

reduce() публичный статический Метод

Reduce any iterable collection using the callback. In case of an array, array_reduce is used.
public static reduce ( callable $f, $xs, null $initial = null ) : mixed | null
$f callable
$xs
$initial null
Результат mixed | null

repeat() публичный статический Метод

repeat the value n times in a lazy fashion.
public static repeat ( integer $n, mixed $val ) : Generator
$n integer
$val mixed
Результат Generator

rgen() публичный статический Метод

Return an Iterator allowing a rewind on the given generator.
public static rgen ( Generator $xs ) : RewindableIterator
$xs Generator
Результат RewindableIterator

str() публичный статический Метод

Create a string with the given char array.
public static str ( array $chars ) : string
$chars array
Результат string

take() публичный статический Метод

Return at most $n elements from the given iterable collection in a lazy fashion.
public static take ( integer $n, Iterator $it ) : Generator
$n integer
$it Iterator
Результат Generator

takeNth() публичный статический Метод

Return every Nth elements in the given collection in a lazy fashion.
public static takeNth ( integer $n, $coll ) : Generator
$n integer
$coll
Результат Generator