summaryrefslogtreecommitdiffstats
path: root/ex/2/48.rkt
blob: 50b4984e2903f7193208ec3f5d88ee8289895fb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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")