HW4

posted Sep 26, 2012, 6:52 PM by Samuel Konstantinovich   [ updated Sep 26, 2012, 6:52 PM ]
;1 Define a quotient function without using quotient
(define myQuotient (lambda (a b) (/ (- a (modulo a b))b)))
;OR
(define myQuotient (lambda (a b)(-(/ a b)(/(modulo a b)b))))

;2 Is the Nth place even
;by defining a 2nd function
(define getNthPlace (lambda (x place)(modulo (quotient x place)10)))
(define isTheNthPlaceEven? (lambda (x place) (even? (getNthPlace x place))))
;OR writing it as one function
(define isTheNthPlaceEven? (lambda (x place) (even? (modulo (quotient x place)10))))

;3 Gravity is rad...
;two ways to define G:
(define G (* 6.673 0.00000000001))
(define G 6.673e-011)
;The function itself:
(define gravity (lambda (m1 m2 D)(/(* m1 m2 G)(* D D))))
Comments