-2

This is a program in Haskell that with let:

   slope (x1,y1) (x2,y2) = let dy = y2-y1
    dx = x2-x1
    in dy/dx

Now I try in where but it's not working properly actually I am unable to build a allgo for where would you like to write it for me :

slope (x1,y1) (x2,y2)
 | x<0 ="wronge input"
 |otherwise ="I don't know what Im doing"
 where x=dy/dx
 dy=(y2-y1)
 dx=(x2-x1)
Shahzad
  • 33
  • 1
  • 7

1 Answers1

3

Indent x=,dy=,dx= on the same column:

slope (x1,y1) (x2,y2)
 | x<0      = "wrong input"
 |otherwise = "I don't know what Im doing"
 where x=dy/dx
       dy=(y2-y1)
       dx=(x2-x1)

The indentation rule is: after where (and let,do,case of) the very first non-space (non-comment) word starts a block of entries, and all those must start on the same column of that word. Above the word is x. You can indent in other ways, of course: e.g.

slope (x1,y1) (x2,y2)
 | x<0      = "wrong input"
 |otherwise = "I don't know what Im doing"
 where
   x=dy/dx
   dy=(y2-y1)
   dx=(x2-x1)
Community
  • 1
  • 1
chi
  • 111,837
  • 3
  • 133
  • 218