SHARE
TWEET

VP5

a guest Nov 18th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DOMAINS
  2.  
  3. author, title, jenre, publisher = string
  4. year, page_count= integer
  5.    
  6. FACTS
  7. book(author, title, jenre, year, publisher, page_count)
  8. fantasy(author, title, year, publisher, page_count)
  9. fantastic(author, title, year, publisher, page_count)
  10. determ operator(integer,integer)
  11.  
  12. PREDICATES
  13.  
  14. nondeterm sorter
  15. nondeterm printer_fantasy
  16. nondeterm printer_fantastic
  17.  
  18. nondeterm average_by_genre(string)
  19.  
  20.  
  21. CLAUSES
  22.  
  23. %book("ÀÂÒÎÐ", "ÍÀÇÂÀÍÈÅ", "ÆÀÍÐ", ÃÎÄ, "ÈÇÄÀÒÅËÜÑÒÂÎ", ÊÎË-ÂÎ ÑÒÐÀÍÈÖ).
  24. book("Äæ.Ð.Ð. Ìàðòèí", "Ìåæåâîé ðûöàðü(Àíòîëîãèÿ 'Ëåãåíäû')", "Ôýíòåçè", 1999, "ÀÑÒ", 78).
  25. book("Äæ.Ð.Ð. Ìàðòèí", "Ïðèñÿæíûé ðûöàðü(Àíòîëîãèÿ 'Ëåãåíäû')", "Ôýíòåçè", 2006, "ÀÑÒ", 94).
  26. book("Äæ.Ð.Ð. Ìàðòèí", "Ïëàìÿ è êðîâü", "Ôýíòåçè", 2018, "ÀÑÒ", 384).
  27. book("Ãàððè Òåðòëäàâ", "Ôëîò âòîðæåíèÿ", "Ôàíòàñòèêà", 2003, "Ýêñìî", 704).
  28. book("Ãàððè Òåðòëäàâ", "Îòâåòíûé óäàð", "Ôàíòàñòèêà", 2003, "Ýêñìî", 720).
  29. book("Ãàððè Òåðòëäàâ", "Îêî çà îêî", "Ôàíòàñòèêà", 2003, "Ýêñìî", 704).
  30. book("Ãàððè Òåðòëäàâ", "Âåëèêèé ïåðåëîì", "Ôàíòàñòèêà", 2004, "Ýêñìî", 704).
  31. book("Àíäðåé Âàëåíòèíîâ", "Âîëîíò¸ðû ×åëêåëÿ", "Ôàíòàñòèêà", 1996, "Àâòîð", 310).
  32. book("Àíäðåé Âàëåíòèíîâ", "Ñòðàæ ðàíû", "Ôàíòàñòèêà", 1996, "Àâòîð", 280).
  33. book("Àíäðåé Âàëåíòèíîâ", "Íåñóùèé ñâåò", "Ôàíòàñòèêà", 1996, "Àâòîð", 310).
  34. sorter:-retract(book(A,B,"Ôàíòàñòèêà",D,E,F)), asserta(fantastic(A,B,D,E,F)) ;
  35.     retract(book(A,B,"Ôýíòåçè"   ,D,E,F)), asserta(fantasy  (A,B,D,E,F)).
  36. printer_fantasy:-retract(fantasy(A,B,D,E,F)), write("Ôýíòåçè ", B, " : ", A, ", ", D, ", ", E, ", ", F),fail.
  37. printer_fantastic:-retract(fantastic(A,B,D,E,F)), write("Ôàíòàñòèêà ", B, " : ", A, ", ", D, ", ", E, ", ", F),fail.
  38. average_by_genre(X):-
  39.     assert(operator(0,0)),
  40.     book(_,_,X,_,_,F),
  41.     retract(operator(SUMM,COUNT)),
  42.     NEWSUMM = SUMM + F,
  43.     NEWCOUNT = COUNT + 1,
  44.     asserta(operator(NEWSUMM, NEWCOUNT)),
  45.     fail.
  46. average_by_genre(X):-
  47.     write("Ñðåäíåå êîë-âî ñòðàíèö â æàíðå ", X, " - "),
  48.     retract(operator(SUMM,COUNT)),
  49.     AVERAGEPAGECOUNT = SUMM/COUNT,
  50.     write(AVERAGEPAGECOUNT),nl.
  51. GOAL
  52. sorter,average_by_genre("Ôýíòåçè").
  53. %sorter,printer_fantasy,printer_fantastic,nl,fail.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top