Skip to content

Instantly share code, notes, and snippets.

@uberEllis
Last active December 17, 2015 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uberEllis/5547621 to your computer and use it in GitHub Desktop.
Save uberEllis/5547621 to your computer and use it in GitHub Desktop.
A doodle in PHP
<?php
function word_live_as_one($imagination) {
global $world;
foreach ($imagination as $thought) {
switch ($thought) {
case 'heaven':
case 'hell':
case 'countries':
case 'possessions':
$dreamer = FALSE;
break;
default:
$dreamer = TRUE;
}
if (in_array($thought, $world->things_to_die_for) || (in_array($thought, $world->things_to_kill_for)) {
$dreamer = FALSE;
}
if (in_array($thought, $world->need_for_greed) || (in_array($thought, $world->need_for_hunger)) {
$dreamer = FALSE;
}
}
if ($dreamer == 'FALSE') {
echo "I hope some day you'll join us";
}
else {
$imagination = array(
'people living for today',
'people living life in peace',
'people sharing all the world',
);
}
return $imagination;
}
?>
@xsyn
Copy link

xsyn commented May 16, 2013

I see no reason to unset the variables that are never set. I also think that $imagination is is not unaligned with $greed, $hunger, $possessions.

I think you should they should be unset as a function of the world living as one. So thinking this through:

I would call the top level function image, which you are then passing the things which should be imagined.

Thoughts?

@xsyn
Copy link

xsyn commented May 16, 2013

On further reflection, you probably want a recursive function in some functional language. But….

@perceptum
Copy link

xsyn++

This is very cool though

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