PHP Class QCheck\FP

Show file Open project: steos/php-quickcheck Class Usage Examples

Public Methods

Method 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 method

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

assoc() public static method

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
return array

comp() public static method

Compose the two functions
public static comp ( callable $f, callable $g ) : callable
$f callable
$g callable
return callable

concat() public static method

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

cycle() public static method

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

excludeNth() public static method

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

filter() public static method

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

iterator() public static method

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

map() public static method

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
return Generator

method() public static 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
return callable

partial() public static method

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

partition() public static method

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

property() public static method

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

push() public static method

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
return array

range() public static method

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

realize() public static method

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

reduce() public static method

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
return mixed | null

repeat() public static method

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

rgen() public static method

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

str() public static method

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

take() public static method

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
return Generator

takeNth() public static method

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