Consider the followig code, compiled in clingo.
File test.lp
. Compile command: clingo 0 test.lp
.
col(("rot";"blau")).
freq("rot","hell",2). freq("rot","dunkel",2). freq("rot","hell",5).
freq("blau","hell",20). freq("blau","dunkel",30). freq("blau","hell",50).
freq_sum(C,F) :- F = #sum{ X : freq(C,_,X) }, col(C).
%% does not work: >>error: syntax error, unexpected [, expecting {<<
% freq_sum(C,F) :- F = #sum[ X : freq(C,_,X) ], col(C).
#show freq_sum/2.
The code should compute the sum of frequencies for each colour. For "red"
, this should be 9
and for “blue"
this should be 100
. For "red"
the value 2
is counted twice. When I replace {...}
by […]
, which should make the list an ordered list and deliver the ordered sum, the compiler complains error: syntax error, unexpected [, expecting {
. I have clingo version 4.5.4
. Is there something wrong with my code or with my compiler?
Can someone please tell me, how I can perform an ordered sum in asp?