Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created April 8, 2015 13:40
Show Gist options
  • Save walterdavis/6b8284044c4a85ee994e to your computer and use it in GitHub Desktop.
Save walterdavis/6b8284044c4a85ee994e to your computer and use it in GitHub Desktop.
<?php
$rows = 106;
function seek_row_count($rows, $target = 35){
$result = $rows % $target;
if($result == 0 || $result > 1) return $target;
return seek_row_count($rows, --$target);
}
print seek_row_count($rows, 35);
?>
@walterdavis
Copy link
Author

Using tail-call recursion to split a large collection into a set of slices without any widows at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment