WHY WHY WHY?
Why create such a sadistic and evil language?
I am taking a course in AI and it is the language everything is done in. Look at this garbage!
Code:
(setq lista (cons 'a (cons 'b (cons 'c (cons 'd nil)))))
(setq listb (cons 'c (cons 'd (cons 'e (cons 'f nil)))))
(defun is_in (x y) (if(equalp y ()) () (if(equalp x (car y)) (car y) (is_in x (c
dr y)))))
(defun intersection (x y) (if (equalp x ()) () (if(not(equalp (is_in(car x) y) (
)) ) (cons (car x) (intersection (cdr x) y)) (intersection (cdr x) y) )))
(defun difference (x y) (if(equalp x ()) () (if(equalp (is_in (car x) y) ()) (co
ns (car x) (union (cdr x) y)) (union (cdr x) y)) ) )
(defun union (x y) (if(equalp y ()) () (if(equalp x ()) (cons (car y) (union(x (
cdr y) )) (if(equalp (car x) (is_in (car x) y)) (difference (cdr x) y ) (cons (c
ar x) (difference (cdr x) y)))))))
(defun subset (x y) (if(equalp x ()) '(y) (if(is_in (car x) y) (subset (cdr x) y
) () ) ))
(defun reverse (x) (if(equalp x ()) () (append (reverse (cdr x)) (list (car x) )
)))
(defun remove (x y) (if(equalp y ()) () (if(equalp x (car y)) (remove x (cdr y))
(cons (car y) (remove x (cdr y))))))
(defun replaceall (x y z) (if(equalp (car z) ()) () (if (equalp x (car z)) (cons
y (replaceall x y (cdr z))) (cons (car z) (replaceall x y (cdr z))))))
Is that not the ugliest thing you have every seen? It was easier to do it this way then to use the languages weird implementation of for loops.
And I still haven't gotten union to work.
Someone please explain it to me.
And does anyone know of a GUI editor that will work in OS X that can balance these blasted parens? Emacs is out because it is just to annoying to use.