Skip to main content

List/Collection Helpers

This section contains information about composable functions, some of the higher-order mold and others that are not - those that typically transform lists or objects.

map#

map(function, list)

map :: (a -> b) -> [a] -> [b]

The map function applies a function to all the elements in a list in a single iteration.

Since:

  • bingo-functional - v1.5.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The function to map onto the values in a list
  • list - The array|object whose values are to be transformed
use function Chemem\Bingo\Functional\map;
$result = map(fn (int $x) => $x ** 2, [3, 9, 12]); // prints [9, 81, 144]

mapDeep#

mapDeep(function, list)

mapDeep :: (a -> b) -> [a] -> [b]

The mapDeep function is a map implementation that transforms all values in a multi-dimensional list.

Since:

  • bingo-functional - v1.10.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The function to map onto values in the list
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\mapDeep;
$result = mapDeep('strtoupper', ['foo', ['bar', ['baz']]]);

filter#

filter(function, list)

filter :: (a -> Bool) -> [a] -> [a]

The filter operation makes it possible to select list values based on their conformance to the boolean predicate that shapes the return value of a filter function.

Since:

  • bingo-functional - v1.5.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The filter function
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\filter;
$result = filter(  fn (string $str): bool => mb_strlen($str, 'utf-8') <= 3,  ['foo', 'bar', 'foo-bar']);

filterDeep#

filterDeep(function, list)

filterDeep :: (a -> Bool) -> [a] -> [a]

The filterDeep function performs the filter operation on multi-dimensional lists.

Since:

  • bingo-functional - v1.11.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The filter function
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\filterDeep;
$result = filterDeep(  fn (int $x): bool => $x % 2 == 0,  [9, 12, [4, 18, 24, [6, 80, 7]]]);

Note: The function does not alter list dimensionality as of versions 1.13.0 and newer.

reject#

reject(function, list)

reject :: (a -> Bool) -> [a] -> [a]

The reject function returns, from a list, all values that do not conform to a boolean predicate. It is the opposite of the filter operation.

Since:

  • bingo-functional - v1.10.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The filter function
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\reject;
$result = reject(  fn (string $str): bool => mb_strlen($str, 'utf-8') <= 3,  ['foo', 'bar', 'foo-bar']);

reduce/fold#

fold(function, list, accumulator)

fold :: (a -> b -> c) -> [b] -> a -> a

The fold function - otherwise known as reduce - is one used purposely to transform a collection into a single value.

Since:

  • bingo-functional - v1.5.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The fold function (takes an accumulator and list item values as arguments)
  • list - The array|object whose values are to be evaluated
  • accumulator - The accumulator value
use function Chemem\Bingo\Functional\{fold, concat};
$result = fold(fn (string $acc, string $val): string => (  concat('_', $acc, $val)), ['bar', 'baz'], 'foo');

foldRight#

foldRight(function, list, accumulator)

foldRight :: (a -> b -> c) -> [b] -> a -> a

Transforms a list into a single value. The iteration order for this function is right-to-left, however.

Since:

  • bingo-functional - v1.5.0
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The fold function (takes an accumulator and list item values as arguments)
  • list - The array|object whose values are to be evaluated
  • accumulator - The accumulator value
use function Chemem\Bingo\Functional\{foldRight, concat};
$result = foldRight(  fn (string $acc, string $val): string => concat('_', $acc, $val),  ['bar', 'baz'],  'foo',);

transduce#

transduce(transducer, iterator, list, accumulator)

transduce :: (c -> c) -> ((a, b) -> a) -> a -> [b] -> a

Performs a series of pipelined map and filter operations.

A transducer is an efficient list-transforming function pipeline. Transducers allow those who choose to use them to compose multiple discretionary functions that directly change or filter out list elements. They effectively combine map, filter, and fold operations.

Since:

  • bingo-functional - v2.0.0

Arguments:

  • transducer - An arbitrary list transformation function
  • iterator - A special function that returns a single result from a transduce operation (this function is called a step function in other contexts)
  • list - The array|object whose values are to be evaluated
  • accumulator - The accumulator value
use function Chemem\Bingo\{  Functional as f,  Functional\Transducer as t,};
$result = f\transduce(  f\composeRight(    t\map(fn (int $x) => $x ** 2),    t\map(fn (int $x) => $x + 3),    t\filter(fn (int $x) => $x % 2 === 0),  ),  fn ($acc, $val, $idx) => f\extend($acc, [$idx => $val]),  [    'foo' => 1,    'bar' => 3,    'baz' => 4,  ],  [],);

any#

any(function, list)

any :: (a -> Bool) -> [a] -> Bool

The any function checks if at least a single value in a list structure conforms to the boolean predicate in a function signature.

Since:

  • bingo-functional - v1.8.1
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The predicate function
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\any;
$result = any(fn (int $x): bool => $x % 2 != 0, [2, 4, 18, 90]);

every#

every(function, list)

every :: (a -> Bool) -> [a] -> Bool

The every function checks if a boolean assertion in a function holds for every value in a list.

Since:

  • bingo-functional - v1.8.1
  • bingo-functional-js - v0.1.0

Arguments:

  • function - The predicate function
  • list - The array|object whose values are to be evaluated
use function Chemem\Bingo\Functional\every;
$result = every(fn (int $x): bool => $x % 2 != 0, [2, 4, 18, 90]);

extend#

extend(...lists)

extend :: [a] -> [b] -> [a, b]

The extend function is inspired by a similar bilby.js functional library. This helper is, in essence, used on lists and allows one to concatenate them.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • lists - The arrays|objects to merge
use function Chemem\Bingo\Functional\extend;
$result = extend(['foo', 'bar'], ['baz'], ['fooz']);

fill#

fill(list, value, start, end)

fill :: [a, b] -> c -> Int -> Int -> [a, c]

The fill function replaces the values in a specified index range with an arbitrary value.

Since:

  • bingo-functional - v1.8.0

Argument(s):

  • list - An arbitrary list
  • value - A discretionary value to insert into array
  • start - The first index in fill range
  • end - The final index in fill range
use function Chemem\Bingo\Functional\fill;
$fill = fill([2, 4, 6, 7], 'foo', 1, 3);

partition#

partition(number, list)

partition :: Int -> [a] -> [[a]]

The partition function one which can be used to create a multidimensional array expressed as a collection of smaller arrays of a defined size.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • number - The number of partitions to create
  • list - The array to partition
use function Chemem\Bingo\Functional\partition;
$result = partition(2, ['foo', 'bar', 'baz', 'boo']);

partitionBy#

partitionBy(partitionCount, list)

partitionBy :: Int -> [a] -> [[a]]

The partitionBy function creates a partitioned list with a defined partition size.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • partitionCount - The size of the list partitions to create
  • list - The list to partition
use function Chemem\Bingo\Functional\partition;
$result = partitionBy(1, ['foo', 'bar', 'baz', 'boo']);

head#

head(list)

head :: [a] -> a

The head function outputs the first value in a list.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - The list from which the first value is to be extracted
use function Chemem\Bingo\Functional\head;
$result = head(['foo', 'bar', 'baz', 'boo']);

last#

last(list)

last :: [a] -> a

The head function outputs the last value in a list.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - The list from which the last value is to be extracted
use function Chemem\Bingo\Functional\last;
$result = last(['foo', 'bar', 'baz', 'boo']);

tail#

tail(list)

tail :: [a] -> [a]

The tail function outputs all elements in a list except the first one.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
use function Chemem\Bingo\Functional\tail;
$result = tail(['foo', 'bar', 'baz', 'boo']);

pluck#

pluck(list, key, default = null)

pluck :: [a] -> b -> b

Plucking selects an item from a list by key|index.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
  • key - The key to search for
  • default - The default value the function returns if the requested key is absent
use function Chemem\Bingo\Functional\pluck;
$result = pluck(['foo' => 'foo', 'boo' => 'baz'], 'boo');

pluckPath#

pluckPath(keys, list, default = null)

pluckPath :: [a] -> [b] -> c -> b

Returns the value associated with the index at the end of a traversable list path.

Since:

  • bingo-functional - v1.13.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • keys - A traversable list path
  • list - An arbitrary list
  • default - A default value
use function Chemem\Bingo\Functional\pluckPath;
$result = pluckPath(['foo', 'socials', 0], [  'foo' => [    'socials' => ['github', 'twitter']  ],], 'github');

pluckDeep#

pluckDeep(key, list)

pluck :: [a] -> b -> b

Recursively searches a list for the value associated with a specified key.

Since:

  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
  • key - The key to search for
use function Chemem\Bingo\Functional\pluckDeep;
$res = pluckDeep([  'a' => 2,  'b' => 3,  'c' => (object) ['a' => 5, 'd' => 12]], 'a');

pick#

pick(list, value, default = null)pick(list, value)

pick :: [a] -> a -> a

Plucking selects an item from a list.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
  • value - The value to search for
  • default - The default value the function returns if the requested value is absent
use function Chemem\Bingo\Functional\pick;
$result = pick(['foo', 'bar'], 'foo');

indexOf#

indexOf(list, value, default = null)indexOf(list, value)

indexOf :: [b] -> b -> a

Returns the index that corresponds to an item in a list.

Since:

  • bingo-functional - v1.8.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
  • value - The list item to search for
  • default - The value to which the function defaults if the specified item is absent
use function Chemem\Bingo\Functional\indexOf;
$result = indexOf(['foo' => 'foo', 'baz' => 'bar'], 'bar');

indexesOf#

indexesOf(list, value, default = null)

indexesOf :: [b] -> b -> [a]

Returns a list containing the indexes that correspond to an item in a multidimensional list.

Since:

  • bingo-functional - v1.12.0
  • bingo-functional-js - v0.1.0

Arguments:

  • list - An arbitrary list
  • value - The list item to search for
  • default - The value to which the function defaults if the specified item is absent
use function Chemem\Bingo\Functional\indexesOf;
$result = indexesOf([  'foo' => 'foo',  'bar' => [    ['foo', 'baz', ['boo', 'foo']]  ]], 'foo');

firstIndexOf#

firstIndexOf(list, value)

firstIndexOf :: [a] -> a -> b -> a

Computes the first index that corresponds to a specified list item.

Since:

  • bingo-functional - v1.13.0

Arguments:

  • list - An arbitrary list
  • value - The list item to search for
use function Chemem\Bingo\Functional\firstIndexOf;
$first = firstIndexOf(['foo' => 2, 'bar' => 'bar'], ...range(2, 6)], 'bar');

lastIndexOf#

lastIndexOf(list, value)

lastIndexOf :: [a] -> a -> b -> a

Computes the last index that corresponds to a specified list item.

Since:

  • bingo-functional - v1.13.0

Arguments:

  • list - An arbitrary list
  • value - The list item to search for
use function Chemem\Bingo\Functional\lastIndexOf;
$last = lastIndexOf(['foo' => 2, 'bar' => 'bar'], ...range(2, 6)], 2);

has#

has(list, value)

has :: [a] -> b -> Bool

Checks if a list contains a specified value.

Since:

  • bingo-functional - v2.0.0

Argument(s):

  • list - An arbitrary list
  • value - The value to search for
use function Chemem\Bingo\Functional\has;
$check = has([(object) range(1, 5), 'foo', 'bar'], 3);

keysExist#

keysExist(list, ...keys)

keysExist :: [a, b] -> c -> d -> Bool

Determines if specified keys exist in a list.

Since:

  • bingo-functional - v1.0.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
  • keys - The keys to search for
use function Chemem\Bingo\Functional\keysExist;
$result = keysExist((object) ['foo' => 'foo', 'bar' => 'bar'], 'fooz', 'boo');

toPairs#

toPairs(list)

toPairs :: [a, b] -> [[c, a], [d, b]]

Combines key-value pairs into discrete array pairs.

Since:

  • bingo-functional - v1.6.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - The list from which to form pairs
use function Chemem\Bingo\Functional\toPairs;
$pairs = toPairs(['foo' => 'foo', 'bar' => 'bar']);

fromPairs#

fromPairs(list)

fromPairs :: [[c, a], [d, b]] -> [a, b]

The fromPairs function forms key-value pairs from discrete array pairs.

Since:

  • bingo-functional - v1.6.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - The list of pairs from which to create a key-value predisposition
use function Chemem\Bingo\Functional\fromPairs;
$result = fromPairs([  ['foo', 'foo'],  ['bar', 'bar']]);

intersperse#

intersperse(element, list)

intersperse :: b -> [a] -> [a, b]

Creates a list with an arbitrary value interposed between elements.

Since:

  • bingo-functional - v1.13.0

Argument(s):

  • element - An arbitrary value
  • list - An arbitrary list
use function Chemem\Bingo\Functional\intersperse;
$result = intersperse('foo', range(1, 5));

intersects#

intersects(fst, snd)

intersects :: [a] -> [b] -> Bool

Checks if two lists have at least one item in common.

Since:

  • bingo-functional - v1.12.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • fst - The first list to compare
  • snd - The second list to compare
use function Chemem\Bingo\Functional\intersects;
$result = intersects(  ['foo', 'bar', 'baz'],  [1, 3, 9, 12]);

flatten#

flatten(list)

flatten :: [[a]] -> [a]

Reduces list dimensionality to one.

Since:

  • bingo-functional - v1.6.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list to flatten
use function Chemem\Bingo\Functional\flatten;
$result = flatten(['foo', 'bar', ['foo' => 'boo', ['baz' => 'baz']]]);

dropLeft#

dropLeft(list, number, start)

dropLeft :: [a, b] -> Int -> [b]

Removes elements from the front of a list.

Since:

  • bingo-functional - v1.6.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - The array from which items are to be purged
use function Chemem\Bingo\Functional\dropLeft;
$result = dropLeft([  'foo' => 'foo',  'bar' => 'bar',  'baz' => 'baz'], 2);

dropRight#

dropRight(list, number, start)

dropRight :: [a, b] -> Int -> [a]

Removes elements from the back of a list.

Since:

  • bingo-functional - v1.6.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - The array from which items are to be purged
use function Chemem\Bingo\Functional\dropRight;
$result = dropRight([  'foo' => 'foo',  'bar' => 'bar',  'baz' => 'baz'], 2);

max#

max(list)

max :: [a] -> Float

Computes the largest number in a collection.

Since:

  • bingo-functional - v1.8.1
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
use function Chemem\Bingo\Functional\max;
$max = max([4, 90, 2, 3]);

min#

min(list)

min :: [a] -> Float

Computes the lowest value in an array.

Since:

  • bingo-functional - v1.8.1
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
use function Chemem\Bingo\Functional\min;
$min = min([4, 90, 2, 3]);

mean#

mean(list)

mean :: [a, b] -> Float

Computes the average of the values in an array.

Since:

  • bingo-functional - v1.8.1
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
use function Chemem\Bingo\Functional\mean;
$mean = mean(range(7, 21));

countOfKey#

countOfKey(list, key)

countOfKey :: [a] -> b -> Int

The countOfKey function returns the total number of appearances a key makes in a list of any dimensionality.

Since:

  • bingo-functional - v1.13.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
  • key - The key to search for
use function Chemem\Bingo\Functional\countOfKey;
$count = countOfKey([  'foo',  ['bar' => 'bar', ['foo']],  ['baz' => 'foo']], 0);

countOfValue#

countOfValue(list, value)

countOfValue :: [a] -> a -> Int

The countOfKey function returns the total number of appearances an item makes in a list of any dimensionality.

Since:

  • bingo-functional - v1.13.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • list - An arbitrary list
  • value - A discretionary value to search for
use function Chemem\Bingo\Functional\countOfValue;
$count = countOfValue([  'foo',  ['bar' => 'bar', ['foo']],  ['baz' => 'foo']], 'foo');

difference#

difference(...lists)

difference :: Eq a => [a] -> [a] -> [a]

Compares lists and returns the elements absent from their intersection.

Since:

  • bingo-functional - v1.13.0

Argument(s):

  • lists - Arbitrary lists to compare
use function Chemem\Bingo\Functional\difference;
$result = difference(['foo', 'bar'], ['foo', 'baz'], ['fooz', 'boo']);

union#

union(...lists)

union :: [a] -> [b] -> [a, b]

Combines multiple arrays into a single array of unique elements.

Since:

  • bingo-functional - v1.12.0

Argument(s):

  • lists - The lists to merge
use function Chemem\Bingo\Functional\union;
$result = union(range(1, 5), [3, 4, 8, 9, 6]);

unionWith#

unionWith(function, ...lists)

unionWith :: ([a] -> [b] -> Bool) -> [a] -> [b] -> [c]

Combines multiple arrays on fulfillment of a condition.

Since:

  • bingo-functional - v1.12.0

Argument(s):

  • function - The function on which to base the union
  • list - The lists to merge
use function Chemem\Bingo\Functional\{  unionWith,  isArrayOf};
$union = unionWith(fn (array $num, array $str): bool => (  isArrayOf($num) == 'integer' && isArrayOf($str) == 'string'), range(1, 5), ['foo', 'bar']);

addKeys#

addKeys(list, ...keys)

addKeys :: [a] -> b -> [a]

The addKeys function outputs the contents of an array which correspond to specified keys.

Since:

  • bingo-functional - v1.10.0

Argument(s):

  • list - An arbitrary list
  • keys - The keys to include in final set
use function Chemem\Bingo\Functional\addKeys;
$result = addKeys([  'hbo' => ['game of thrones', 'insecure'],  'netflix' => ['daredevil', 'luke cage'],  'amc' => ['breaking bad'],  'cw' => ['smallville', 'arrow']], 'hbo', 'netflix', 'amc');

renameKeys#

renameKeys(list, keys)

renameKeys :: [a] -> [b] -> [a]

Renames the keys in a list.

Since:

  • bingo-functional - v1.13.0

Argument(s):

  • list - The list whose keys are to be renamed
  • keys - The key replacement list
use function Chemem\Bingo\Functional\renameKeys;
$result = renameKeys([  'ace411',  'twitter' => '@agiroLoki',], ['github']);

assoc#

assoc(key, value, list)

assoc :: a -> b -> [c] -> [b]

Creates a shallow clone of a list (array or object) with an overwritten value at a specified index.

Since:

  • bingo-functional - v2.0.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • key - A list key whose associate value is to be overwritten
  • value - An arbitrary value with which to perform the overwrite
  • list - A list to clone
use function Chemem\Bingo\Functional\assoc;
$result = assoc('foo', 2, [  'bar' => range(1, 5),  'foo' => 'FOO',]);

assocPath#

assocPath(keys, value, list)

assocPath :: [a] -> b -> [c] -> [b]

Creates a shallow clone of a list with an overwritten value assigned to the index at the end of a traversable path.

Since:

  • bingo-functional - v2.0.0
  • bingo-functional-js - v0.1.0

Argument(s):

  • keys - A traversable list of keys
  • value - An arbitrary value with which to perform the overwrite
  • list - A list to clone
use function Chemem\Bingo\Functional\assocPath;
$result = assocPath(['foo', 'socials', 1], 'github', [  'foo' => [    'socials' => ['twitter', 'facebook']  ],  'bar' => 2,]);

omit#

omit(list, ...keys)

omit :: [a] -> b -> [a]

Removes specified keys from a list.

Since:

  • bingo-functional - v1.10.0

Argument(s):

  • list - An arbitrary list
  • keys - The keys to purge from a list
use function Chemem\Bingo\Functional\omit;
$result = omit([  'hbo' => ['game of thrones', 'insecure'],  'netflix' => ['daredevil', 'luke cage'],  'amc' => ['breaking bad'],  'cw' => ['smallville', 'arrow']], 'cw');

where#

where(list, search)

where :: [[a], [b]] -> [a] -> [[a]]

The where function searches a multi-dimensional array using a fragment of a sub-array defined in said multi-dimensional array.

Since:

  • bingo-functional - v1.8.1

Argument(s):

  • list - The list to search
  • search - The list fragment that is the basis for the search
use function Chemem\Bingo\Functional\where;
$result = where([  ['pos' => 'pg', 'name' => 'magic'],  ['pos' => 'sg', 'name' => 'jordan']], ['name' => 'magic']);

groupBy#

groupBy(list, key)

groupBy :: [a] -> b -> [a]

The groupBy function is one that sorts a multi-dimensional array by a defined key.

Since:

  • bingo-functional - v1.8.1

Argument(s):

  • list - The list to sort
  • key - The key to use for the grouping
use function Chemem\Bingo\Functional\groupBy;
$result = groupBy([  ['pos' => 'sg', 'name' => 'jordan'],  ['pos' => 'pg', 'name' => 'magic'],  ['pos' => 'sg', 'name' => 'wade']], 'pos');

unique#

unique(list)

unique :: [a, b, a] -> [a, b]

Purges all duplicates from a list.

Since:

  • bingo-functional - v1.6.0

Argument(s):

  • list - An arbitrary list
use function Chemem\Bingo\Functional\unique;
$result = unique([1, 4, 5, 4, 2, 2]);

sizeOf#

sizeOf(list)

sizeOf :: [a] -> Int

Computes the size of an array or object.

Since:

  • bingo-functional-js - v0.1.0

Argument(s):

  • list - The artifact whose size is to be computed
import { sizeOf } from 'bingo-functional-js'
const size = sizeOf({ foo: 'foo', bar: 'bar' })

zip#

zip(...lists)

zip :: [a] -> [b] -> [(a, b)]

Combines multiple lists into a multi-dimensional list of sub-arrays that are index-specific groupings.

Since:

  • bingo-functional - v1.0.0

Argument(s):

  • list - An arbitrary list
use function Chemem\Bingo\Functional\zip;
$result = zip(['foo', 'bar', 'baz'], range(12, 15));

zipWith#

zipWith(function, ...lists)

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

Combines, via function, multiple lists into a multi-dimensional list of sub-arrays that are index-specific groupings.

Since:

  • bingo-functional - v1.12.0

Argument(s):

  • function - The zip function
  • list - An arbitrary list
use function Chemem\Bingo\Functional\zipWith;
$result = zipWith(  fn (int $x, int $y): int => $x + $y,  range(2, 3),  range(15, 16));

unzip#

unzip(list)

unzip :: [(a, b)] -> ([a], [b])

Transforms a zipped list into one containing the initially grouped lists.

Since:

  • bingo-functional - v1.0.0

Argument(s):

  • list - A zipped list
use function Chemem\Bingo\Functional\{zip, unzip};
$result = unzip(zip(['foo', 'bar'], range(3, 4)));

Function aliases

Some functions specified in this section have alternate names. Shown below is a table of the said functions and their respective aliases.

FunctionJavaScriptPHPAlias
foldYesYesreduce, reduceLeft
foldRightYesYesreduceRight
partialYesYespartialLeft