2016-04-09 22 views
0

benim işlevlerinden biri ile bağlantılı olarak "kon" kullanarak "ve" doğru biraz sorun olan:Lisp kullanarak Ve Şartlar açıklamada

(cond (and (find 'hello actionsems) 
     (find 'formal actionsems)) 
     (print "Chatterbot: Hello, how are you?") 
    (and (find 'hello actionsems) 
     (find 'informal actionsems)) 
     (print "Chatterbot: Hey, how's it going?") 
    ) 

ben "ilişkisiz değişken almaya çalışılıyor söyledi am . sözdiziminde bir hata yaptım burada "vE" birisi işaret Could

cevap

3

COND makro koşullar listesini alır ve sırayla bunları değerlendirmek CLHS gerçek sözdizimi:?.

Syntax: 
cond {clause}* => result* 

clause::= (test-form form*) 

Arguments and Values: 
test-form---a form. 
forms---an implicit progn. 
results---the values of the forms in the first clause whose test-form yields true, or the primary value of the test-form if there are no forms in that clause, or else nil if no test-form yields true. 

Bunu aldıktan sonra durum değerlendirmeniz aşağıdaki gibi olmalıdır:

(cond ((and (find 'hello actionsems) 
      (find 'formal actionsems)) 
     (print "Chatterbot: Hello, how are you?")) 
     ((and (find 'hello actionsems) 
      (find 'infomal actionsems)) 
     (print "Chatterbot: Hey, how's it going?")))