[英]How to write prolog program and queries
編寫Prolog程序以進行跟蹤。 我寫了所有東西,我需要知道我寫的最后兩個是否正確。
1. saman likes maths.
2. saman likes science.
3. udara likes maths.
4. fazal likes science.
5. fazal likes music.
6. geetha likes history.
7. geetha likes science.
8. geetha likes music.
9. those who like maths and science will follow engineering for advance level.
10. those who likes history or music will follow art for advance level.
這對最后兩個正確嗎?
student(X):- like(X,maths_and_science),follow(X,engineering).
student(X):- likes(X,history_or_music), follow(X,art).
我不知道如何編寫以下Prolog查詢。
1) Does saman like maths or music? 2) Who likes science and music? 3) who will do engineering?
請幫我。
- 那些喜歡數學和科學的人會跟隨工程學進階。
- 那些喜歡歷史或音樂的人會跟隨藝術前進。
這對最后兩個正確嗎?
否。可能是:
will_follow(Student, engineering) :-
likes(Student, maths),
likes(Student, science).
will_follow(Student, art) :-
likes(Student, history) ;
likes(Student, music).
1)薩滿喜歡數學還是音樂?
likes(saman, art) ; likes(saman, music). % intentionally incorrect
2)誰喜歡科學和音樂?
likes( Who, science) , likes( Who, maths). % intentionally incorrect
3)誰來做工程?
will_follow( Who, arts ). % intentionally incorrect
由於這看起來像是一項作業,因此我故意在各處使用錯誤的名稱。 您將不得不更正那些。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.