Discuss and learn Lisp programming of all dialects
This is a read-only archive of lispforum.com. The forum was locked to new users and
posts and is preserved here as static HTML from a database snapshot taken on
2019-09-07.
When writing dolist could we check 2 lists, if there is no match in the first list then it should go to the second list. And also in dolist could we append to the list that we are checking?
(setq KB '((or a b) (or not c a) (or not b f) (or not d b) (or c d) (or not c e) (or not f g) (or not e f) (not g)))
The first time sos is (not g), It compares with the rest (reverse kb). so it finds a match 6 times. But if I change the order of kb, then Error: In - of (NIL 1) arguments should be of type NUMBER.
But i need to search the kb until I find a match. How to implement this?
Sorry for too many questions. Hope you can help me. Thanks.
Did you see this? I have no idea if that is near your question, but those NOTs and ORs seem to imply it.
It is better to refer not to the variables, but to what they are/mean? Or in terms of a function having certain inputs, and what it is to output? I dubbed KB to be called clause; a combination of (OR ..) true if test on one succeed,(returning first one) (AND ...) true only if test on all succeeds, (NOT ...) true if none of the tests succeed. But i am not sure this is what you want.
Sorry but I don't understand your function completely. What is the "about" that you are using. I don't use "and". And you are comparing only and, or & not. I need to compare the symbols also, in the process I get new elements that I need to append to the list and search in them also until i get a null when i resolve(i.e a (f) & (not f) which should give nil) and then I stop the function.
Essentially(for default TEST), it assigns a true/false value based on a symbol(about) and clause. If the clause is (OR &rest rest) then it returns true only if one or more of the elements of REST os equal to the symbol, or one of the clauses returns true. Similarly for AND, where all of them must be true, and NOT where all of them must be false. Some examples:
(clause-says 'a 'a) ;-> EQL so true
(clause-says 'a '(or b c d)) ; none of them is A, false.
(clause-says 'a '(not c d)) ; none of them is A, true
(clause-says 'a '(or (not a) (and b c d))) ;False
I'm not sure I understand what's going on here, but if you want dolist to iterate over list a, and then if it's still iterating, iterate over list b, you can usually do: