Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;TEST
- ;;1
- (defun triangle-center (tri)
- (point (/ (+ (point-x (v1 tri)) (point-x (v2 tri)) (point-x (v3 tri))) 3)
- (/ (+ (point-y (v1 tri)) (point-y (v2 tri)) (point-y (v3 tri))) 3)))
- ;;2
- (defun sum-digits (x)
- (if (< x 10)
- x
- (+ (rem x 10) (sum-digits (floor x 10)))))
- ;;3
- ;;(let ((last (cons 'B 'C))) (cons last (cons last 'A)))
- ;;4
- (defun even-elements (list)
- (cond ((null list) nil)
- ((evenp (car list)) (cons (car list) (even-elements (cdr list))))
- (t (even-elements (cdr list)))))
- ;;5
- (defun my-set-intersection-2 (a b)
- (cond ((null a) nil)
- ((null b) nil)
- ((contains b (car a)) (cons (car a) (my-set-intersection-2 (cdr a) b)))
- (t (my-set-intersection-2 (cdr a) b))))
- (defun contains (list a)
- (cond ((null list) nil)
- ((= (car list) a) t)
- ((> (car list) a) nil)
- (t (contains (cdr list) a))))
- ;;6
- (defun my-set-intersection (a &rest rest)
- (cond ((null rest) a)
- (t (apply #'my-set-intersection (my-set-intersection-2 a (car rest)) (cdr rest)))))
- ;;7
- (defun seq-interleave (a b)
- (lambda (x) (if (evenp x) (funcall a (/ x 2)) (funcall b (floor (/ x 2)) ))))
- (defun find-path (tree n)
- (cond ((null tree) nil)
- ((eql (car tree) n) (list (car tree)))
- ((null (cdr tree)) nil)
- (t (let ((next (find-path-children (cdr tree) n)))
- (if (eql next nil) nil (cons (car tree) next))))))
- (defun find-path-children (children n)
- (cond ((null children) nil)
- (t (let ((child (find-path (car children) n)))
- (if (eql child nil) (find-path-children (cdr children) n) child)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement