-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b3549
commit 17e1af0
Showing
3 changed files
with
13,951 additions
and
5,422 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#lang racket | ||
(define (unless pred con alt)(if pred alt con)) | ||
(unless (> 10 5) (/ 1 0) 5) | ||
(define (unless pred (con lazy) alt)(if pred alt con)) | ||
(unless (> 10 5) (/ 1 0) 5) | ||
(define (unless pred (con lazy-memo) alt)(if pred alt con)) | ||
(unless (> 10 5) (/ 1 0) 5) | ||
(define (fib (n lazy-memo)) | ||
(let fib-iter (((a lazy-memo) 1) ((b lazy-memo) 0) (count n)) | ||
(if (= count 0) | ||
b | ||
(fib-iter (+ a b) | ||
a | ||
(- count 1))))) | ||
|
||
(define (fib n) | ||
(if (= n 1) | ||
0 | ||
(if (= n 2) | ||
1 | ||
(+ (fib (- n 1)) (fib (- n 2)))))) | ||
|
||
(define (fib (n lazy)) | ||
(if (= n 1) | ||
0 | ||
(if (= n 2) | ||
1 | ||
(+ (fib (- n 1)) (fib (- n 2)))))) | ||
|
||
(define (fib (n lazy-memo)) | ||
(if (= n 1) | ||
0 | ||
(if (= n 2) | ||
1 | ||
(+ (fib (- n 1)) (fib (- n 2)))))) |
Oops, something went wrong.