Created
February 20, 2017 00:50
-
-
Save tbogdala/6c184beea91f67339edadd4062b1277c to your computer and use it in GitHub Desktop.
A few test routines in gimmick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (begin | |
| (define fib (lambda (n) | |
| (if (< n 2) | |
| 1 | |
| (+ (fib (- n 1)) (fib (- n 2)))))) | |
| (define fib2 (lambda (n) | |
| (begin | |
| (define fib2Rec (lambda (a b n) | |
| (if (eqv? n 0) | |
| a | |
| (fib2Rec b (+ a b) (- n 1))))) | |
| (fib2Rec 0 1 n)))) | |
| (define s1 (lambda (n) | |
| (if (eqv? n 0) | |
| 0 | |
| (+ n (s1 (- n 1)))))) | |
| (define s2 (lambda (n acc) | |
| (if (eqv? n 0) | |
| acc | |
| (s2 (- n 1) (+ acc n))))) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment