fork download
  1. % =================================================================
  2. % データ定義(ファクト)
  3. % product(商品名, 価格, 評価, レビュー数)
  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.  
  14. % 1. 指定された予算(MaxPrice)以下の商品を検索する
  15. affordable_product(Name, MaxPrice) :-
  16. product(Name, Price, _, _),
  17. Price <= MaxPrice.
  18.  
  19. % 2. 指定された評価(MinRating)以上の高評価商品を検索する
  20. high_rating_product(Name, MinRating) :-
  21. product(Name, _, Rating, _),
  22. Rating >= MinRating.
  23.  
  24. % 3. おすすめ商品(例:評価が4.5以上、かつレビュー数が15件以上)
  25. recommended_product(Name) :-
  26. product(Name, _, Rating, ReviewCount),
  27. Rating >= 4.5,
  28. ReviewCount >= 15.
Success #stdin #stdout #stderr 0.02s 6956KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/i1SJID/prog:17:9: Syntax error: Operator expected
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit