I am engaged in artificial intelligence, and we were given a program for writing. The program seems to be simple, and all the other students did it in java. However, I know that this can be done in LISP with less work. Well. Print less. But I've been reading about LISP for a week now, and I am amazed at this. I intend to learn more and use LISP much more than just this class. I am 23 years old and I am learning a language formed in 1958. It's romantic. I really like avoiding my mouse like a plague.
The example he gives tells the whole program. He notes that he uses recursion, not prog. I understand what that means, at least.
(rewrite '(or a (and b (not (or c d)))))
--> (OR A (AND B (AND (NOT C) (NOT D))))
(rewrite '(and a (or b (not (and c (and d e))))))
--> (AND A (OR B (NOT C) (OR (NOT D) (NOT E)))))
I understand the laws of De Morgan. I just don’t understand how I should deal with this! That I'm still ... embarrassing. My notebook is filled with pages of my pages, trying to figure it out. I will give you the closest attempt in the simplest case:
(not (or a b))
I believe that if I can handle this, I can be fine to handle the rest. May be. I made a function called "arrow", and this statement above is what I call an advanced list.
(defun boom (sexp)
(let ((op (car (car (cdr sexp))))
(operands (cdr (car (cdr sexp))))))
(if (equal op 'and)
(setcar sexp 'or)
(setcar sexp 'and))
(print operands)
(print sexp))
;end boom
I print at the end for debugging. Changes in the operands of the list do not reflect changes in the original sexp (huge ones give in to me).
Tell me that I have a fake, and guide me.
source
share