/*
I'm wondering where to cut the cake between prolog and pico/pilog
and thought I'd post a quick example to illustrate i.e.
initially I won't have individual values for variables
but a list of possibles and want the pc to pick the right values for me
using a system of (cast in stone) equations as a filter...just two in this
example.
Apparently for this to work I need to be use integers.
In reality the figures have decimal points so pico's fixed pt. maths looks
a good fit.
Any thoughts re how to approach this in pico/pilog much appreciated.
*/
:- use_module(library(clpfd)).
main :-
Lsales = [100,200,300],
Lcogs = [10,20,30],
Lgross_profit = [160,180,200],
member(Sales,Lsales),
member(Cogs,Lcogs),
member(Gross_profit,Lgross_profit),
Ltax = [5,10,15],
Lnet_profit = [100,170,300],
member(Tax,Ltax),
member(Net_profit,Lnet_profit),
Gross_profit #= Sales - Cogs,
Net_profit #= Gross_profit - Tax,
format("Gross_profit ~w Sales ~w Cogs ~w\n",[Gross_profit,Sales,Cogs]),
format("Net_profit ~w Gross_profit ~w Tax
~w\n",[Net_profit,Gross_profit,Tax]).
/*
?- main.
Gross_profit 180 Sales 200 Cogs 20
Net_profit 170 Gross_profit 180 Tax 10
true ;
false.
*/
As an aside....re the output of 'Ls...is it possible to remove the double
quotes when printing the symbols or CARs of the resultant list?/
I read that initially the VAL is the same as the symbol...and it
is....complete with double quotes.
Thank you in anticipation and best regards
Dean