Rev | Line | |
---|

[37401] | 1 | (import simple-loops simple-tests) |
---|

| 2 | |
---|

| 3 | (define-test (loops?) |
---|

| 4 | (equal? |
---|

| 5 | (let ((lst '())) |
---|

| 6 | (do-times i (+ 2 3) |
---|

| 7 | (set! lst (cons i lst))) |
---|

| 8 | lst) |
---|

| 9 | '(4 3 2 1 0)) |
---|

| 10 | (equal? |
---|

| 11 | (let ((lst '())) |
---|

| 12 | (do-list i '(1 2 3) |
---|

| 13 | (set! lst (cons i lst))) |
---|

| 14 | lst) |
---|

| 15 | '(3 2 1)) |
---|

| 16 | (equal? |
---|

| 17 | (let ((lst '())) |
---|

| 18 | (do-for i (1 5) (set! lst (cons i lst))) |
---|

| 19 | (reverse lst)) |
---|

| 20 | '(1 2 3 4)) |
---|

| 21 | (equal? |
---|

| 22 | (let ((lst '())) |
---|

| 23 | (do-for i (1 65 i) (set! lst (cons i lst))) |
---|

| 24 | (reverse lst)) |
---|

| 25 | '(1 2 4 8 16 32 64)) |
---|

| 26 | (equal? |
---|

| 27 | (let ((n 4) (lst '())) |
---|

| 28 | (do-while (<= 0 n) |
---|

| 29 | (set! lst (cons n lst)) |
---|

| 30 | (set! n (- n 1))) |
---|

| 31 | lst) |
---|

| 32 | '(0 1 2 3 4)) |
---|

| 33 | (equal? |
---|

| 34 | (let ((n 4) (lst '())) |
---|

| 35 | (do-until (> 0 n) |
---|

| 36 | (set! lst (cons n lst)) |
---|

| 37 | (set! n (- n 1))) |
---|

| 38 | lst) |
---|

| 39 | '(0 1 2 3 4)) |
---|

| 40 | (equal? |
---|

| 41 | (let ((n 3) (lst '())) |
---|

| 42 | (do-forever |
---|

| 43 | (if (zero? n) (exit lst)) |
---|

| 44 | (set! lst (cons 'a lst)) |
---|

| 45 | (set! n (- n 1)))) |
---|

| 46 | '(a a a)) |
---|

| 47 | ) |
---|

| 48 | |
---|

| 49 | (compound-test (LOOPS) |
---|

| 50 | (loops?)) |
---|

**Note:** See

TracBrowser
for help on using the repository browser.