# Różnice

Różnice między wybraną wersją a wersją aktualną.

 — pl:prolog:pllib:polygon_area [2019/06/27 15:50] (aktualna) Linia 1: Linia 1: + ====== Polygon area ====== + {{tag>​geometry recursion lists + geometry recursion lists}} + ===== Description ===== + Area is the area of the polygon enclosed by the list of points chain, where the coordinates of each point are represented by a pair (X,Y) of integers. + + **Source**: ​ The Art of Prolog + ===== Download ===== + Program source code: {{polygon_area.pl}} + ===== Listing ===== + + /* + ​area(Chain,​Area) :- + Area is the area of the polygon enclosed by the list of points + Chain, where the coordinates of each point are represented by + a pair (X,Y) of integers. + */ + ​area([Tuple],​0). + ​area([(X1,​Y1),​(X2,​Y2)|XYs],​Area) :- + area([(X2,​Y2)|XYs],​Area1), ​ + Area is (X1*Y2-Y1*X2)/​2 + Area1. + + %  Program 8.8  Computing the area of polygons + + + ​ + ===== Comments =====
pl/prolog/pllib/polygon_area.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)