PHP Class QCheck\FP

Afficher le fichier Open project: steos/php-quickcheck Class Usage Examples

Méthodes publiques

Méthode Description
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.

Method Details

args() public static méthode

Returns a function that simply return that arguments it receives.
public static args ( ) : callable
Résultat callable

assoc() public static méthode

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
Résultat array

comp() public static méthode

Compose the two functions
public static comp ( callable $f, callable $g ) : callable
$f callable
$g callable
Résultat callable

concat() public static méthode

Lazily iterate over all iterable collection given as parameters in order.
public static concat ( ) : Generator
Résultat Generator

cycle() public static méthode

Iterate infinitely on the result of the given callable.
public static cycle ( callable $f ) : Generator
$f callable
Résultat Generator

excludeNth() public static méthode

Return a copy of the array with the Nth element removed.
public static excludeNth ( integer $n, array $xs ) : array
$n integer
$xs array
Résultat array

filter() public static méthode

Filter the given iterable collection using the callback in a lazy way.
public static filter ( callable $f, $coll ) : Generator
$f callable
$coll
Résultat Generator

iterator() public static méthode

Return an iterator for the given collection if possible.
public static iterator ( $xs ) : ArrayIterator
$xs
Résultat ArrayIterator

map() public static méthode

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
Résultat Generator

method() public static méthode

Return a function that calls the given method (first parameter) on any given object with the given arguments (remaining parameters).
public static method ( ) : callable
Résultat callable

partial() public static méthode

Return a callable with all the given arguments already bound to the function (first parameter).
public static partial ( ) : callable
Résultat callable

partition() public static méthode

Return the given collection partitioned in n sized segments in a lazy fashion.
public static partition ( integer $n, $coll ) : Generator
$n integer
$coll
Résultat Generator

property() public static méthode

Return a function that returns the given property on any given object.
public static property ( string $name ) : callable
$name string
Résultat callable

push() public static méthode

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
Résultat array

range() public static méthode

If $max is negative, the range will be infinite.
public static range ( integer $min, integer $max ) : Generator
$min integer
$max integer
Résultat Generator

realize() public static méthode

Transform the given iterable collection to a "real" array.
public static realize ( array | Iterator $it ) : array
$it array | Iterator
Résultat array

reduce() public static méthode

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
Résultat mixed | null

repeat() public static méthode

repeat the value n times in a lazy fashion.
public static repeat ( integer $n, mixed $val ) : Generator
$n integer
$val mixed
Résultat Generator

rgen() public static méthode

Return an Iterator allowing a rewind on the given generator.
public static rgen ( Generator $xs ) : RewindableIterator
$xs Generator
Résultat RewindableIterator

str() public static méthode

Create a string with the given char array.
public static str ( array $chars ) : string
$chars array
Résultat string

take() public static méthode

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
Résultat Generator

takeNth() public static méthode

Return every Nth elements in the given collection in a lazy fashion.
public static takeNth ( integer $n, $coll ) : Generator
$n integer
$coll
Résultat Generator