Skip to content

Instantly share code, notes, and snippets.

@youngnh
youngnh / gist:6346490
Created August 26, 2013 20:48
CPS Combinators in Java
public class Next<A, B, C> extends Task<A, C> {
private Task<A, B> task;
private Task<B, C> nextTask;
public Next(Task<A, B> task, Task<B, C> nextTask) {
this.task = task;
this.nextTask = nextTask;
}
(define tolerance 0.00001)
(define (fixed-point f first-guess)
(define (close-enough? v1 v2)
(< (abs (- v1 v2)) tolerance))
(define (try guess)
(let ((next (f guess)))
(if (close-enough? guess next)
next