Skip to content

Instantly share code, notes, and snippets.

View billhails's full-sized avatar

Bill Hails billhails

View GitHub Profile
@billhails
billhails / lambda.fn
Last active June 30, 2018 09:14
Example lambda interpreter written in F-natural
{
// very simple environment, one binding per frame
typedef environment { frame(string, expression, environment) | root }
// lookup access to the environment
fn lookup {
(str, frame(str, value, _)) { value }
(str, frame(_, _, parent)) { lookup(str, parent) }
(str, root) { error("mce symbol not defined " @@ str) }
}
@billhails
billhails / 01_factorial_plain.php
Created June 30, 2018 10:55
examples of continuation-passing style in PHP
<?php
function factorial($n) {
if ($n === 0) {
return 1;
} else {
return $n * factorial($n - 1);
}
}