Skip to content

Instantly share code, notes, and snippets.

@rintaun
Last active December 16, 2015 13:49
Show Gist options
  • Save rintaun/5444841 to your computer and use it in GitHub Desktop.
Save rintaun/5444841 to your computer and use it in GitHub Desktop.
<?php
$empty = function($selector) {
return $selector(null, null, true);
};
$prepend = function($el, $list) {
return function($selector) use ($el, $list) {
return $selector($el, $list, false);
};
};
$head = function($list) {
return $list(function($h, $t, $e) {
return $h;
});
};
$tail = function($list) {
return $list(function($h, $t, $e) {
return $t;
});
};
$is_empty = function($list) {
return $list(function($h, $t, $e) {
return $e;
});
};
$list = $prepend("asdf", $empty);
var_dump($head($list));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment