fork download
  1. Prolog
  2. % データ定義(ファクト)
  3. product(item1, 3000, 4.8, 20).
  4. product(item2, 1800, 4.2, 200).
  5. product(item3, 5000, 4.9, 5).
  6. product(item4, 2500, 4.5, 80).
  7.  
  8. % 1. 指定された予算(MaxPrice)以下の商品を検索する
  9. affordable_product(Name, MaxPrice) :-
  10. product(Name, Price, _, _),
  11. Price <= MaxPrice.
  12.  
  13. % 2. 指定された評価(MinRating)以上の高評価商品を検索する
  14. high_rating_product(Name, MinRating) :-
  15. product(Name, _, Rating, _),
  16. Rating >= MinRating.
  17.  
  18. % 3. おすすめ商品(例:評価が4.5以上、かつレビュー数が15件以上)
  19. recommended_product(Name) :-
  20. product(Name, _, Rating, ReviewCount),
  21. Rating >= 4.5,
  22. ReviewCount >= 15.
Success #stdin #stdout #stderr 0.02s 6956KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Sw9e7q/prog:2:13: Syntax error: Operator expected
ERROR: /home/Sw9e7q/prog:11:9: Syntax error: Operator expected
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit