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.180 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.179 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.178 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.177 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.176 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.175 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.174 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.173 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.172 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.171 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.170 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.169 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.167 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.166 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.165 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.164 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.163 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.162 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.161 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.160 tracks/php/exercises/accumulate/example.php