fork download
  1. % 商品データ
  2. product(item1,3000,4.8,20).
  3. product(item2,1800,4.2,200).
  4. product(item3,5000,4.9,5).
  5. product(item4,2500,4.5,80).
  6.  
  7. % 評価4.5以上の商品
  8. high_rating(Item) :-
  9. product(Item, _, Rating, _),
  10. Rating >= 4.5.
  11.  
  12. % 3000円以下の商品
  13. cheap(Item) :-
  14. product(Item, Price, _, _),
  15. Price =< 3000.
  16.  
  17. % レビュー数100件以上の商品
  18. popular(Item) :-
  19. product(Item, _, _, Reviews),
  20. Reviews >= 100.
  21.  
  22. % おすすめ商品(評価4.5以上かつ3000円以下)
  23. recommended(Item) :-
  24. product(Item, Price, Rating, _),
  25. Price =< 3000,
  26. Rating >= 4.5.:- set_prolog_flag(verbose,silent).
  27. :- prompt(_, '').
  28. :- use_module(library(readutil)).
  29.  
  30. main:-
  31. process,
  32.  
  33. process:-
  34. /* your code goes here */
  35.  
  36. :- main.
Success #stdin #stdout #stderr 0.04s 6164KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/qeZjRP/prog:26:16: Syntax error: Operator expected