Skip to content

Instantly share code, notes, and snippets.

@JanDupal
Created August 15, 2011 23:06
Show Gist options
  • Save JanDupal/1148113 to your computer and use it in GitHub Desktop.
Save JanDupal/1148113 to your computer and use it in GitHub Desktop.
Vector interpolation in Haskell
size :: [Double] -> Double
size = sqrt . sum . map (**2)
add :: [Double] -> [Double] -> [Double]
add = zipWith (+)
normalize :: [Double] -> [Double]
normalize a = map (/ size a) a
interpolate :: [Double] -> [Double] -> [Double]
interpolate = (.)(normalize . take 3) . add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment