Search found 12 matches

by prathyuguduri
Tue Apr 27, 2010 11:38 am
Forum: Common Lisp
Topic: can we search 2 lists at a time?
Replies: 6
Views: 10524

Re: can we search 2 lists at a time?

@Jasper 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 sear...
by prathyuguduri
Tue Apr 27, 2010 10:24 am
Forum: Common Lisp
Topic: can we search 2 lists at a time?
Replies: 6
Views: 10524

Re: can we search 2 lists at a time?

(defun process (kb) (let* ((sos (first (last KB))) (soslist (list sos)) (clauses (rest (reverse kb))) (pred1 (first (last (butlast kb)))) (notpos (- (position (second sos) pred1) 1))) (let ((pred nil)) (dolist (clause clauses) (when (or (search (list (second sos)) clause) (search (list (first sos))...
by prathyuguduri
Tue Apr 27, 2010 12:29 am
Forum: Common Lisp
Topic: can we search 2 lists at a time?
Replies: 6
Views: 10524

can we search 2 lists at a time?

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) (no...
by prathyuguduri
Mon Apr 26, 2010 6:40 pm
Forum: Common Lisp
Topic: How to write this functionality
Replies: 3
Views: 3900

Re: How to write this functionality

@ nuntius Thank you for the reply. I have implemented what you told me but it is still just comparing only the next list in the list of lists to another list, and if its not there then i get an error i.e (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) (o...
by prathyuguduri
Fri Apr 23, 2010 12:17 pm
Forum: Common Lisp
Topic: How to write this functionality
Replies: 3
Views: 3900

How to write this functionality

What I want to do is for each sos (could be 1 or 2 elements like (g) or (not g)) I want to check if "g" is in the clauses(reverse kb) list. If there is a match put it in the "pred" list and do one of the "and's" How do we write someth like "for each sos loop...&quo...
by prathyuguduri
Fri Apr 23, 2010 12:15 pm
Forum: Common Lisp
Topic: Why doesn't "cond" or "if" work inside when
Replies: 9
Views: 9905

Re: Why doesn't "cond" or "if" work inside when

The problem is not with the "cond". The sos has an element that is not in the pred1 and so the error is coming. But this is not the functionality I want. What I want to do is for each sos (could be 1 or 2 elements like (g) or (not g)) I want to check if "g" is in the clauses(reve...
by prathyuguduri
Fri Apr 23, 2010 11:24 am
Forum: Common Lisp
Topic: Why doesn't "cond" or "if" work inside when
Replies: 9
Views: 9905

Re: Why doesn't "cond" or "if" work inside when

@nuntius

Thanks, ya I collapsed those do's. I'm completely new to LISP so I donno the alternatives.
by prathyuguduri
Fri Apr 23, 2010 11:23 am
Forum: Common Lisp
Topic: Why doesn't "cond" or "if" work inside when
Replies: 9
Views: 9905

Re: Why doesn't "cond" or "if" work inside when

@Jasper

my bad. I guessed it's not understandable.
I'm comparing if a list has a "not" so I used equal. I know its complicated but the error is at the point I tried to bold.
It is not executing the cond statement that is embedded inside those when and loop.
by prathyuguduri
Fri Apr 23, 2010 12:22 am
Forum: Common Lisp
Topic: Why doesn't "cond" or "if" work inside when
Replies: 9
Views: 9905

Why doesn't "cond" or "if" work inside when

I have written a "cond" inside "when" which is inside "loop". But it doesn't get evaluated. I have also tried "if". They independently exe in the interpreter but when written inside the loop Error: In - of (NIL 1) arguments should be of type NUMBER. What am I ...
by prathyuguduri
Wed Apr 21, 2010 6:13 pm
Forum: Common Lisp
Topic: list initialization in a function
Replies: 4
Views: 4685

Re: list initialization in a function

@nuntius Thank you for the reply. I have replaced if with when. And the mistake I was doing is that I was trying to see the value of the variable in the interpreter after the function got executed. The variable scope is local to the function so I was getting the error that the list sos is unbound. T...