Created
August 15, 2011 23:06
-
-
Save JanDupal/1148113 to your computer and use it in GitHub Desktop.
Vector interpolation in Haskell
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
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