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.58 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.57 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.56 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.55 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.54 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.53 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.52 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.51 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.50 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.49 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.48 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.47 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.46 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.45 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.44 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.43 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.42 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.41 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.40 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.39 tracks/php/exercises/accumulate/example.php