-
Notifications
You must be signed in to change notification settings - Fork 0
/
exe2.3.lsp
34 lines (30 loc) · 860 Bytes
/
exe2.3.lsp
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
(define (line x1 y1 x2 y2)
(define first (cons x1 y1))
(define last (cons x2 y2))
(cons first last))
(define (first len) (car len))
(define (last len) (cdr len))
(define (xpoint p) (car p))
(define (ypoint p) (cdr p))
(define (printpnts p)
(newline)
(display "(")
(display (xpoint p))
(display ",")
(display (ypoint p))
(display ")")
0)
(define (perimeter r) (* 2 (+ (length r) (breadth r))))
(define (area r) (* (length r) (breadth r)))
(define (points_rect xc len b)
(let ((a xc)
(b (cons (+ (xpoint xc) len) (ypoint xc)))
(c (cons (+ (xpoint xc) len) (+ (ypoint xc) b)))
(d (cons (xpoint xc) (+ (ypoint xc) b))))
(cons a (cons b (cons c d))) ))
(define (parametric_rect a len b)
(cons a (cons len b)))
(define (length r)
(car (cdr r)))
(define (breadth r)
(cdr (cdr r)