Heronian triangles: Difference between revisions

m
→‎{{header|Logtalk}}: Tidied up some lines that wrapped.
(→‎{{header|Lua}}: Added Logtalk solution.)
m (→‎{{header|Logtalk}}: Tidied up some lines that wrapped.)
Line 3,043:
gather_primitive_heronians(Primitives),
list::length(Primitives, L),
logtalk::print_message(information, heronian, 'There are ~w primitive Heronian triangles with sides under 200.~n'+[L]),
'There are ~w primitive Heronian triangles with sides under 200.~n'+[L]),
 
list::sort(order_area, Primitives, AreaSorted),
list::take(10, AreaSorted, Area10),
logtalk::print_message(information, heronian, @'The first ten found, ordered by area, are:\n'),
@'The first ten found, ordered by area, are:\n'),
display_each_element(Area10),
 
list::sort(order_perimeter, Primitives, PerimeterSorted),
list::take(10, PerimeterSorted, Perimeter10),
logtalk::print_message(information, heronian, @'The first ten found, ordered by perimeter, are:\n'),
@'The first ten found, ordered by perimeter, are:\n'),
display_each_element(Perimeter10),
 
bagof(Element, A^B^C^E^(list::member((A,B,C,210.0,E), Primitives), Element = (A,B,C,210.0,E)), Area210),
logtalk::print_message(information, heronian, @'The list of those with an area of 210 is:\n'),
@'The list of those with an area of 210 is:\n'),
display_each_element(Area210).
 
Line 3,063 ⟶ 3,067:
display_element((A,B,C,Area,Perimeter)) :-
format(F),
logtalk::print_message(information, heronian, F+[A, B, C, Area, Perimeter]).
F+[A, B, C, Area, Perimeter]).
 
display_each_element(L) :-
34

edits