Created
October 22, 2018 01:25
-
-
Save axgle/748d3da24c9d67f0aafa7b39ab354a67 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 | |
//stack is for LookBack (2018-10-22) | |
$d=range(1,10); | |
function p($d) {return print_r($d);} | |
p($d); | |
$ret = | |
array_reduce( | |
$d, | |
function($s,$e){ | |
$top = array_pop($s);//look back | |
// $s[]=$top; | |
$s[]=$top+$e; | |
return $s; | |
}, | |
[0] | |
); | |
p($ret); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment