fork download
  1. Prolog
  2. % =================================================================
  3. % データ定義(ファクト)
  4. % =================================================================
  5. product(item1, 3000, 4.8, 20).
  6. product(item2, 1800, 4.2, 200).
  7. product(item3, 5000, 4.9, 5).
  8. product(item4, 2500, 4.5, 80).
  9.  
  10. % =================================================================
  11. % ルール定義
  12. % =================================================================
  13. % おすすめ商品(AIが独自に定義:評価4.5以上 & レビュー15件以上)
  14. recommended_product(Name, Rating, ReviewCount) :-
  15. product(Name, _, Rating, ReviewCount),
  16. Rating >= 4.5,
  17. ReviewCount >= 15.
  18.  
  19. % =================================================================
  20. % メイン処理(ideone用)
  21. % =================================================================
  22. main :-
  23. write('--- Recommended Products ---'), nl,
  24. forall(recommended_product(Name, Rating, ReviewCount),
  25. format('Item: ~w (Rating: ~w, Reviews: ~w)~n', [Name, Rating, ReviewCount])),
  26.  
  27. :- initialization(main).
Success #stdin #stdout #stderr 0.01s 6104KB
stdin
Standard input is empty
stdout
--- Recommended Products ---
Item: item4 (Rating: 4.5, Reviews: 80)
stderr
ERROR: /home/0rkU73/prog:4:67: Syntax error: Operator expected