Haskell function does not terminate -


I wrote a function in Haskell that takes three points in the plane, and checks whether they are on the straight line, Or turn right or left.

Here is the code:

  detDirection :: point -> Point - & gt; Point - & gt; Direction @ detdirection a @ (dot (x1, y1)) b @ (dot (x2, y2)) c = if (collinear1 abc) then straight and ab = vector [x2 - x1, y2 - y1] angleAbX = angle ab ( Vector [1, 0]) (point (x1, y1) = turnAtP ambulabex (Point (x2, y2)) = turnAtP AC angle in ABX if (y1> y2) then left and right  < / Pre> 

I have tested collinear1 , angle , turnAtP in GHCi, and they all end immediately. detdiirection , however, is going on forever.

Can anyone tell me where is the problem here?

In Haskell, let is a recursive binding, that is, you Let's define the expression can be declared in the manifestation of other variables, when you type

  two now = vector [x2 - x1, y2 - y1] angle ABX = Angle ab (vector [1, 0]) (point (x1, y1) = turnAtP abaabx (point (x2, y2)) = turnAtp ac angle abx  

to X1 , x2 , y1 , and y2 function arguments ul Do not write, but later do not show it on the names declared in the let expression.

  (dot (x3, y3)) = turnAtP ab angleAbX Change the two  point  lines to bind some different variables like (point (x4, y4)) = TurnAtP AC angle ABX  

and accordingly modify your later calculation, and your endless looping will go away.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -