<?php

namespace detail;

function applyForEach($f, $t, $sequence)
{
  foreach($sequence as $i) {
    call_user_func_array($f, array($i, $t[$i]));
  }
}


function applyForEach2($tuple, $_function)
{
  $Indexes = range(0, count($tuple) - 1);
  \detail\applyForEach($_function, $tuple, $Indexes);
}

/* test */

applyForEach2(array(1, 1, 2, 3, 5, 8, 13, 21), function($x, $y) {echo $x . ' => ' . $y . PHP_EOL;});
