[ create a new paste ] login | about

Link: http://codepad.org/1B4b2k6n    [ raw code | output | fork ]

Haskell, pasted on Jun 22:
1
2
3
4
5
6
7
8
9
10
module Collinear (collinear) where

(.-) :: Num a => (a, a) -> (a, a) -> (a, a)
(x1, x2) .- (y1, y2) = (x1 - y1, x2 - y2)

cross :: Num a => (a, a) -> (a, a) -> a
(x1, x2) `cross` (y1, y2) = x1 * y2 - x2 * y1

collinear :: (Num a, Eq a) => (a, a) -> (a, a) -> (a, a) -> Bool
collinear v1 v2 v3 = (v1 .- v2) `cross` (v1 .- v3) == 0


Output:
1
runhugs: can't find "Main" module


Create a new paste based on this one


Comments: