summaryrefslogtreecommitdiffstats
path: root/ex
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-10-14 20:11:45 -0400
committersiddharth <s@ricketyspace.net>2021-10-14 20:11:45 -0400
commit965f2369c786bfb5edfdeb7fb9f661f15cd4184a (patch)
tree8bdd2260de3b66d282f878aae7d07c9288fec120 /ex
parenta8c783445fff7a3f301dbe352ac51895cab9e979 (diff)
ex: do ex 2.48
Diffstat (limited to 'ex')
-rw-r--r--ex/2/48.rkt35
1 files changed, 35 insertions, 0 deletions
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")