Skip to content

Instantly share code, notes, and snippets.

@fredcy
Created March 25, 2016 15:46
Show Gist options
  • Save fredcy/058859db7b0bf3fdcb27 to your computer and use it in GitHub Desktop.
Save fredcy/058859db7b0bf3fdcb27 to your computer and use it in GitHub Desktop.
Try different ways of implementing dot-product in Elm
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