Skip to content

Instantly share code, notes, and snippets.

@kokx
Created May 10, 2011 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokx/965011 to your computer and use it in GitHub Desktop.
Save kokx/965011 to your computer and use it in GitHub Desktop.
<?php
/**
* @pre count($a) == count($b)
* @post \forall ( $x \in \N : \ret[$x] == $a[$x] + $b[$x] )
*/
function add(array $a, array $b)
{
$c = array();
for ($i = 0; $i < count($a); $i++) {
$c[$i] = $a[$i] + $b[$i];
}
return $c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment