Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Vjezbe 4 - 3.11.
- (defun duplanje (l)
- (mapcar #'(lambda (x) (list x x)) l)
- )
- ;Posljednji zadatak
- (defstruct pt
- x
- y
- )
- (defstruct ln
- pt1
- pt2
- )
- (defun udaljenost (p1 p2)
- (sqrt (+ (expt (- (pt-x p1) (pt-x p2)) 2) (expt (- (pt-y p1) (pt-y p2)) 2)))
- )
- (defun srida (l1)
- (make-pt :x (/ (+ (pt-x (ln-pt1 l1)) (pt-x (ln-pt2 l1))) 2) :y (/ (+ (pt-y (ln-pt1 l1)) (pt-y (ln-pt2 l1))) 2))
- )
- (setq points (list (make-pt :x 4 :y 4) (make-pt :x 6 :y 6) (make-pt :x 8 :y 8)))
- (setq lines (list (make-ln :pt1 (nth 0 points) :pt2 (nth 1 points)) (make-ln :pt1 (nth 1 points) :pt2 (nth 2 points))))
- (udaljenost (nth 0 points) (nth 1 points))
- (udaljenost (nth 0 points) (nth 2 points))
- (srida (nth 0 lines))
- (srida (nth 1 lines))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement