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
(define (cbrt-iter guess x) | |
(if (good-enough? guess x) | |
guess | |
(cbrt-iter (improve guess x) | |
x))) | |
(define (improve guess x) | |
(/ (+ (/ x (* guess guess)) (* 2 guess)) 3)) | |
(define (good-enough? guess x) |
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
(define (good-enough? guess x) | |
(< (abs (- (square guess) x)) 0.001)) | |
;; The good-enough? test used in computing square roots will not be | |
;; very effective for finding the square roots of very small numbers. Explain. | |
;; | |
;; good-enough? is not effective for small numbers because the square | |
;; of a small number minus the number quickly becomes less than 0.001. | |
(sqrt 0.00001) |
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
;; What happens when Alyssa uses new-if is that all of new-if's | |
;; "arguments" are evaluated and then given to new-if, as opposed | |
;; to the special form of "if" where the "else" clause is only | |
;; evaluated if the predicate is false. Since there is a | |
;; recursive call in the "else" clause, the call never returns. |
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
;; SICP 1.5 | |
;; Given: | |
;; | |
;; (define (p) (p)) | |
;; | |
;; (define (test x y) | |
;; (if (= x 0) | |
;; 0 | |
;; y)) |
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
SICP 1.4 | |
Fork me. Solve me. | |
==== | |
The procedure's 'leading symbol', the thing that is applied to the arguments, | |
is dynamically determined by an if (aka a ternary expression). Cool, eh? |
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
SICP 1.3 | |
Fork me. Solve me. | |
==== | |
(define (square a) (* a a)) | |
(define (sum-of-squares a b) (+ (square a) (square b))) | |
(define (square-biggest-two a b c smallest) | |
(cond ((= a smallest) (sum-of-squares b c)) | |
((= b smallest) (sum-of-squares a c)) | |
((= c smallest) (sum-of-squares a b)) |
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
SICP 1.2 | |
Fork me. Solve me. | |
==== | |
-71/300 <= | |
(/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 1 5))))) | |
(* 3 (- 6 2) (- 2 7))) |
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
SICP 1.1 | |
Fork me. Solve me. | |
==== | |
10 <= 10 | |
12 <= (+ 5 3 4) | |
8 <= (- 9 1) | |
3 <= (/ 6 2) | |
6 <= (+ (* 2 4) (- 4 6)) | |
a <= (define a 3) |
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
1) Error: | |
test_clone_to_users_assigns_promotion_modules_to_new_promotion(PromotionTest): | |
Errno::ENOENT: No such file or directory - /Users/redsquirrel/Projects/gldl/mimi/repos/trunk/public/system/promotion_images/0000/0001/foo.jpg | |
/opt/local/lib/ruby/1.8/ftools.rb:59:in `stat' | |
/opt/local/lib/ruby/1.8/ftools.rb:59:in `syscopy' | |
/opt/local/lib/ruby/1.8/ftools.rb:89:in `copy' | |
/Users/redsquirrel/Projects/gldl/mimi/repos/trunk/app/models/promotion_image.rb:100:in `clone_to_user' | |
/Users/redsquirrel/Projects/gldl/mimi/repos/trunk/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in `send' | |
/Users/redsquirrel/Projects/gldl/mimi/repos/trunk/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:177:in `method_missing' | |
/Users/redsquirrel/Projects/gldl/mimi/repos/trunk/app/models/promotion.rb:384:in `replace_images_with_new_ones' |
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
DROP PROCEDURE IF EXISTS mailing_prevent_resend; | |
DELIMITER // | |
CREATE PROCEDURE mailing_prevent_resend | |
(target_mailing_id INT, all_audience_user_id INT, prevent_resend BOOLEAN, target_promotion_id INT, force_reconfirm BOOLEAN) | |
BEGIN | |
DROP TEMPORARY TABLE IF EXISTS resulting; |