fork download
  1. % 商品データ: product(商品名, 価格, 評価, 在庫数)
  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. % 利用可能なクエリの例:
  8.  
  9. % 1. 特定の価格以下の商品を探す
  10. % 使用例: cheap_items(2500, Item).
  11. cheap_items(MaxPrice, Item) :-
  12. product(Item, Price, _, _),
  13. Price =< MaxPrice.
  14.  
  15. % 2. 高評価(例: 4.5以上)の商品を探す
  16. % 使用例: popular_items(Item).
  17. popular_items(Item) :-
  18. product(Item, _, Rating, _),
  19. Rating >= 4.5.
  20.  
  21. % 3. 在庫が少ない(例: 50以下)商品を探す
  22. % 使用例: low_stock_items(Item).
  23. low_stock_items(Item) :-
  24. product(Item, _, _, Stock),
  25. Stock =< 50.
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
GNU Prolog 1.4.5 (64 bits)
Compiled Feb  5 2017, 10:30:08 with gcc
By Daniel Diaz
Copyright (C) 1999-2016 Daniel Diaz
| ?-