Skip to content

Instantly share code, notes, and snippets.

@allenluce
Created May 15, 2013 22:19
Show Gist options
  • Save allenluce/5587891 to your computer and use it in GitHub Desktop.
Save allenluce/5587891 to your computer and use it in GitHub Desktop.
function switch_int($which) {
switch($which) {
case 0:
return 2;
case 1:
return 1;
}
}
function switch_string($which) {
switch($which) {
case 'aaaaaaaaaaaaaaa':
return 2;
case 'aaaaaaaxaaaaaaa':
return 1;
}
}
function loop_int($times) {
$acc = 0;
for($i = 0; $i<$times; $i++) {
$choice = $i % 2;
$acc += switch_int($choice);
}
}
function loop_string($times) {
$choices = array('aaaaaaaaaaaaaaa','aaaaaaaxaaaaaaa');
$acc = 0;
for($i = 0; $i<$times; $i++) {
$choice = $choices[$i % 2];
$acc += switch_string($choice);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment