Sha256: 2f7bd659076b9b70114b94518b56ba98e8144941b8224dbbfab8fb7e86e15fbc

Contents?: true

Size: 441 Bytes

Versions: 396

Compression:

Stored size: 441 Bytes

Contents

<?php

/**
 * Given the input array and operation returns an array
 * containing the result of applying that operation
 * to each element of the input array.
 *
 * @param array    $input
 * @param callable $accumulator
 *
 * @return array
 */
function accumulate(array $input, callable $accumulator)
{
    $output = [];

    foreach ($input as $value) {
        $output[] = call_user_func($accumulator, $value);
    }

    return $output;
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.38 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.37 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.36 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.35 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.34 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.33 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.32 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.31 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.30 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.29 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.28 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.27 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.26 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.25 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.24 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.23 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.22 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.21 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.20 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.19 tracks/php/exercises/accumulate/example.php