# perimeter # MODE V = [2]REAL; [] V vt = ((-1, -1), (1, -1), (1, 1), (-1, 1), (-2, 0.3)); PROC dp = (V a, V b)REAL: (REAL ss := 0; FOR j TO UPB a DO ss +:= a[j]*b[j] OD; ss); PROC leng = (V v)REAL: sqrt(dp(v, v)); OP - = (V a, V b)V: (V c; FOR j TO UPB a DO c[j] := a[j] - b[j] OD; c); OP * = (REAL b, V a)V: (V c; FOR j TO UPB a DO c[j] := a[j]*b OD; c); (PROC ie = (INT i, j)REAL: (PROC ise = (INT i, j)REAL: (V tt = (vt[j] - vt[i]); dp(vt[i], (1.0/leng(tt))*tt)); ise(i, j)+ise(j, i)); # Mysterious formula: # (REAL tv := ie(UPB vt, 1); FOR j TO UPB vt - 1 DO tv +:= ie(j, j+1) OD; print(tv))); # Conventional formula: # (REAL ss := leng(vt[1]-vt[UPB vt]); FOR j TO UPB vt - 1 DO ss+:= leng(vt[j]-vt[j+1]) OD; print (ss))