;;; (C) 2008-2009 Dr. Gergo ERDI (in-package :alef) (define-native/strict === (a b) ((t t) bool) (eql (payload a) (payload b))) (parse-and-run `(,@*library* (deftype ring (t) (cons/ring t (ring t))) (define head/ring ((cons/ring y _)) y) (define tail/ring ((cons/ring _ ys)) ys) (define take/ring (0 _) nil) (define take/ring (n (cons/ring y ys)) (cons y (take/ring (- n 1) ys))) (define length/ring^ (x acc y) (if (=== x y) acc (length/ring^ x (+ acc 1) (tail/ring y)))) (define length/ring (r) (length/ring^ r 1 (tail/ring r))) (define start () (let ((r1 (cons/ring 0 r2)) (r2 (cons/ring 1 r3)) (r3 (cons/ring 2 r1))) (length/ring r1)))))