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.119 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.118 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.117 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.116 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.115 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.114 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.113 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.111 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.110 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.109 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.108 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.107 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.106 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.105 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.104 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.103 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.102 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.101 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.100 tracks/php/exercises/accumulate/example.php
trackler-2.2.1.99 tracks/php/exercises/accumulate/example.php