;;;; File: loops-run.scm ;;;; Author: Juergen Lorenz ;;;; ju (at) jugilo (dot) de ;;;; Date: Feb 16, 2011 ;;;; Mar 06, 2011 (require 'loops) (import loops) (define run (lambda () (if (and (equal? (let ((lst '())) (do-times i (+ 2 3) (set! lst (cons i lst))) lst) '(4 3 2 1 0)) (equal? (let ((lst '())) (do-list i '(1 2 3) (set! lst (cons i lst))) lst) '(3 2 1)) (equal? (let ((lst '())) (do-for i (1 5) (set! lst (cons i lst))) (reverse lst)) '(1 2 3 4)) (equal? (let ((lst '())) (do-for i (1 65 i) (set! lst (cons i lst))) (reverse lst)) '(1 2 4 8 16 32 64)) (equal? (let ((n 4) (lst '())) (do-while (<= 0 n) (set! lst (cons n lst)) (set! n (- n 1))) lst) '(0 1 2 3 4)) (equal? (let ((n 4) (lst '())) (do-until (> 0 n) (set! lst (cons n lst)) (set! n (- n 1))) lst) '(0 1 2 3 4)) (equal? (let ((n 3) (lst '())) (do-forever (if (zero? n) (exit lst)) (set! lst (cons 'a lst)) (set! n (- n 1)))) '(a a a))) (print "All tests passed") (print "##### Some tests failed #####"))))