Created
May 29, 2013 22:03
-
-
Save ksomemo/5674201 to your computer and use it in GitHub Desktop.
SICP chapter1
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
;; 1.1.2 | |
(define size 2) | |
(* 5 size) | |
(define pi 3.14159) | |
(define radius 10) | |
(* pi (* radius radius)) | |
(define circumference (* 2 pi radius)) | |
;; 1.1.4 | |
(define (square x) | |
"documentation for square." | |
(* x x)) | |
(define (sum-of-square x y) | |
"documentation for sum-of-square." | |
(+ (square x) (square y))) | |
;; 1.1.6 | |
(define (abs x) | |
"documentation for abs." | |
(cond ((> x 0) x) | |
((= x 0) 0) | |
((< x 0) (- x)))) | |
(define (abs2 x) | |
"documentation for abs2." | |
(cond ((< x 0) (- x)) | |
(else x))) | |
(define (abs3 x) | |
"documentation for abs3." | |
(if (< x 0) | |
(- x) | |
x)) | |
(define (more-than-5-and-less-than-10 x) | |
"documentation for more-than-5-and-less-than-10." | |
(and (> x 5) (< x 10))) | |
(define (is-big-or-equal-other x y) | |
"documentation for is-big-or-equal-other." | |
(or (> x y) (= x y))) | |
(define (is-big-or-equal-other2 x y) | |
"documentation for is-big-or-equal-other2." | |
(not (< x y))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment