(kasten)
;; Define a tuple constructor
(define (make-tuple x y z w)
(list x y z w))
;; Accessor functions
(define (tuple-x t) (list-ref t 0))
(define (tuple-y t) (list-ref t 1))
(define (tuple-z t) (list-ref t 2))
(define (tuple-w t) (list-ref t 3))
;; Predicate to check if it's a vector (w = 0)
(define (vector? t)
(= (tuple-w t) 0.0))
;; Predicate to check if it's a point (w = 1)
(define (point? t)
(= (tuple-w t) 1.0))
;; Create the tuple
(define a (make-tuple 4.3 -4.2 3.1 0.0))
;; Test outputs
(display "a.x = ") (display (tuple-x a)) (newline)
(display "a.y = ") (display (tuple-y a)) (newline)
(display "a.z = ") (display (tuple-z a)) (newline)
(display "a.w = ") (display (tuple-w a)) (newline)
(display "a is a vector: ") (display (vector? a)) (newline)
(display "a is a point: ") (display (point? a)) (newline)