(assoc-ref (car a) 'size))
(killed-ship? s (cdr a))))))
+(define (kill-asteroids s a)
+ (cond ((or (null? s) (null? a)) (values s a))
+ (else
+ (let ((s1 (car s)) (a1 (car a)))
+ (cond ((or (< (sqrt (+ (expt (- (assoc-ref
+
(let ((asteroids #f) (ship #f) (shots #f))
(define (new-game n)
(set! asteroids (make-asteroids n))
(define *pi* (* (asin 1) 2))
+;;; Geometry
+
+(define (degrees-to-radians angle)
+ (/ (* angle *pi*) 180))
+
+(define (radians-to-degrees angle)
+ (/ (* angle 180) *pi*))
+
+(define (distance-between-points p1 p2)
+ (define (add-power-of-two p1 p2)
+ (cond ((null? p1)
+ 0)
+ (else
+ (+ (expt (- (car p1) (car p2)) 2)
+ (add-power-of-two (cdr p1) (cdr p2))))))
+
+ (cond ((not (= (length p1) (length p2)))
+ #f)
+ (else
+ (sqrt (add-power-of-two p1 p2)))))
+
+
;;; Functions
(define (nearest-power-of-two n)
(else (power (* p 2) n))))
(power 1 n))
-(define (degrees-to-radians angle)
- (/ (* angle *pi*) 180))
-
-(define (radians-to-degrees angle)
- (/ (* angle 180) *pi*))
-
(define-macro (pushnew elem list)
`(cond ((not (find (lambda (e) (eq? e ,elem)) ,list))
(set! ,list (cons ,elem ,list)))))