From 965f2369c786bfb5edfdeb7fb9f661f15cd4184a Mon Sep 17 00:00:00 2001 From: siddharth Date: Thu, 14 Oct 2021 20:11:45 -0400 Subject: ex: do ex 2.48 --- ex/2/48.rkt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ex/2/48.rkt diff --git a/ex/2/48.rkt b/ex/2/48.rkt new file mode 100644 index 0000000..50b4984 --- /dev/null +++ b/ex/2/48.rkt @@ -0,0 +1,35 @@ +;;;; License: CC0-1.0 + +#lang racket + +(provide make-segment + start-segment + end-segment) + +(define (make-segment start end) + (cons start end)) + +(define (start-segment s) + (car s)) + +(define (end-segment s) + (cdr s)) + +;;; tests + +(module+ tests + (require rackunit + "46.rkt") + + (define v-start (make-vect 1 2)) + (define v-end (make-vect 3 4)) + + ;; test make-segment + (define seg (make-segment v-start v-end)) + (check-equal? (car seg) v-start) + (check-equal? (cdr seg) v-end) + + ;; test start-segment + (check-equal? (start-segment seg) v-start) + (check-equal? (end-segment seg) v-end) + "all tests ran") -- cgit v1.2.3