Last active
September 30, 2015 20:23
-
-
Save marcioAlmada/8e093863460da624e06e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
function crunch_data(array $data, callable(int $left, int $right): int $callback): array { | |
$result = []; | |
foreach($data as $left => $right) $result[] = $callback($left, $right); | |
return $result; | |
} | |
$crunched = crunch_data([1 => 2, 3 => 4], function(int $left, int $right): int { | |
return $left * $right; | |
}); | |
var_dump($crunched); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment