0
這是結構約邏輯編程和解釋計算機程序的如何獲得與邏輯編程和,而不是價值最高的工作和>
這是理解如何獲得最高的一個簡單的問題值。
這是一個示例數據庫:
((is-student Anna)
(is-student Bart)
(is-student Charlie)
(is-student David)
(is-student Eddy)
(is-student Fanny)
(has-points Anna 73)
(has-points Bart 84)
(has-points Charlie 65)
(has-points David 34)
(has-points Eddy 85)
(has-points Fanny 70))
據我所知,下面的代碼是給學生用他們的觀點總結:
;;; Query input:
(and (is-student ?student1)
(has-points ?student1 ?points1))
;;; Query results:
(and (is-student fanny) (has-points fanny 70))
(and (is-student eddy) (has-points eddy 85))
(and (is-student david) (has-points david 34))
(and (is-student charlie) (has-points charlie 65))
(and (is-student bart) (has-points bart 84))
(and (is-student anna) (has-points anna 73))
同樣與組合,帶和& OR是確定理解。主要是組合並篩選結果。
我在理解下面的代碼時遇到困難讓學生獲得最高分。它看起來很簡單,但我不明白如何與AND組合如何提供最大的價值(點)?
這是我所得到的,當我運行它(在DrRacket),以獲得最高分的學生:
;;; Query input:
(and (is-student ?student1)
(has-points ?student1 ?points1)
(not (and (is-student ?student2)
(has-points ?student2 ?points2)
(lisp-value > ?points2 ?points1))))
;;; Query results:
(and (is-student eddy)
(has-points eddy 85)
(not (and (is-student ?student2)
(has-points ?student2 ?points2)
(lisp-value > ?points2 85))))
如何與第一個工作的第二列表的否定比較? 與第二個AND的每一行相比,第一個結果是每個答案/行嗎? 我不知道如何閱讀/解釋代碼,爲什麼這給了我們正在尋找的?
任何幫助理解這如何提供最高價值將不勝感激!
感謝
PS:我不是以英語爲母語,我的任何語法或拼寫錯誤道歉
謝謝Yoarkyang !,看來我忘了謝謝你!抱歉耽擱了! – Gosa