Created
March 25, 2016 15:46
-
-
Save fredcy/058859db7b0bf3fdcb27 to your computer and use it in GitHub Desktop.
Try different ways of implementing dot-product in Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Graphics.Element exposing (Element, show) | |
main : Element | |
main = | |
show <| dot (Vec2 3 5) (Vec2 5 6) | |
type Vec2 = Vec2 Float Float | |
dot : Vec2 -> Vec2 -> Float | |
dot (Vec2 x1 y1) (Vec2 x2 y2) = | |
(x1 * x2) + (y1 * y2) | |
test = dot (Vec2 3 5) (Vec2 4 6) | |
dot2 (x1, y1) (x2, y2) = | |
(x1 * x2) + (y1 * y2) | |
test2 = dot2 (3, 5) (4, 6) | |
dot3 x1 y1 x2 y2 = | |
(x1 * x2) + (y1 * y2) | |
test3 = dot3 3 5 4 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment