5:- module(calculiva_waste_benchmark,
6 [ waste_dataset_version/1, 7 waste_allowances/1, 8 waste_rows/1, 9 waste_lookup/5, 10 waste_shortfall_pct/3 11 ]). 12:- use_module(library(error)). 13:- use_module(library(lists)). 14:- use_module(calculiva_waste_benchmark_data).
17waste_dataset_version(V) :- dataset_version(V).
20waste_allowances([5, 8, 10, 15]).
26waste_rows(Rows) :-
27 findall(waste_row(F, Or, O, R, K, Ref, C, W, A),
28 summary_row(F, Or, O, R, K, Ref, C, W, A), Rows).
32waste_lookup(F, O, R, K, waste_row(F, Or, O, R, K, Ref, C, W, A)) :-
33 summary_row(F, Or, O, R, K, Ref, C, W, A), !.
38waste_shortfall_pct(waste_row(_, _, _, _, _, _, _, _, A), Allowance, Pct) :-
39 must_be(integer, Allowance),
40 ( memberchk(Allowance, [5, 8, 10, 15])
41 -> true
42 ; domain_error(oneof([5, 8, 10, 15]), Allowance)
43 ),
44 memberchk(allowance(Allowance, _, _, _, Pct, _), A)