Skip to content

Instantly share code, notes, and snippets.

View bollenberger's full-sized avatar

Brian Ollenberger bollenberger

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bollenberger on github.
  • I am briano (https://keybase.io/briano) on keybase.
  • I have a public key ASBgt5Lps2ozqBPCZVIYcFgjOgIrNxglypd03D8suEcIhQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am bollenberger on github.
  • I am briano (https://keybase.io/briano) on keybase.
  • I have a public key whose fingerprint is B665 162B 1261 90EC B890 8BA6 71C5 B1C1 4173 1FED

To claim this, I am signing this object:

<?php
// This will crash the PHP interpreter if run directly, but
// compiling it with our compiler will allow it to loop indefinitely.
function f() {
echo 'hello';
return f();
}
<?php
// Similarly to our Scheme example, we escape from the
// function by calling the continuation with a return value.
echo callcc(function ($c) {
$c(6);
return 5;
});
(call/cc (lambda (c)
(c 6)
5))
(call/cc (lambda (c) (c 5)) ; Returns 5
@bollenberger
bollenberger / basic_closure.scm
Created February 1, 2012 22:05
Basic closure example for Scheme
(define (make-adder a)
(lambda (b) (+ a b)))
(define plus-five (make-adder 5))
(plus-five 4) ; Returns 9
@bollenberger
bollenberger / basic_closure.php
Created February 1, 2012 21:57
Basic closure example for PHP
<?php
function make_adder($a) {
return function ($b) use ($a) {
return $a + $b;
};
}
$plus_five = make_adder(5);