Heronian triangles: Difference between revisions
Content added Content deleted
Ttmrichter (talk | contribs) (→{{header|Logtalk}}: Rewrote the test code to be more comprehensible, adding comments where needed. Changed representation from a tuple to a fact for performance reasons.) |
Ttmrichter (talk | contribs) (→{{header|Logtalk}}: Modified test code to eliminate an unnecessary helper predicate by using a lambda expression.) |
||
Line 3,053: | Line 3,053: | ||
display_each_element(Perimeter10), |
display_each_element(Perimeter10), |
||
% use a lambda expression to reduce the noise of silly little helper predicates |
|||
bagof(Element, |
bagof(Element, {Element, Primitives}/(list::member(Element, Primitives), Element = t(_,_,_,210.0,_)), Area210), |
||
print(@'The list of those with an area of 210 is:\n'), |
print(@'The list of those with an area of 210 is:\n'), |
||
display_each_element(Area210). |
display_each_element(Area210). |
||
% localized helper predicates |
% localized helper predicates |
||
with_area(E, P, N) :- |
|||
list::member(E, P), |
|||
E = t(_,_,_,N,_). |
|||
% display a single element in the provided format |
% display a single element in the provided format |