SICP Exercise 2.47

Question

Here are two possible constructors for frames:

(define (make-frame origin edge1 edge2)
  (list origin edge1 edge2))

(define (make-frame origin edge1 edge2)
  (cons origin (cons edge1 edge2)))

For each constructor supply the appropriate selectors to produce an implementation for frames.

Answer

Very simple:

(define (frame-origin-1 f) (car f))
(define (frame-edge-1-1 f) (cadr f))
(define (frame-edge-2-1 f) (caddr f))

(define (frame-origin-2 f) (car f))
(define (frame-edge-1-2 f) (cadr f))
(define (frame-edge-2-2 f) (cddr f))