Created
January 26, 2018 18:26
-
-
Save AnthonyMikh/67c587a75ed1d8a94e60a47c0789d56c to your computer and use it in GitHub Desktop.
Решение задачи №65 от UniLecs (вариант со списками)
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
import Control.Arrow ((***), (&&&)) | |
shift = go | |
where | |
go [] = [] | |
go (x:xs) = xs ++ [x] | |
shiftedZipWith f = uncurry (zipWith f) . (&&&) id shift | |
shiftedSum = shiftedZipWith (+) | |
shiftedFSub = shiftedZipWith (flip (-)) | |
polygonArea = curry $ (/2) . abs . sum . uncurry (zipWith (*)) . (***) shiftedSum shiftedFSub | |
main = print $ polygonArea [0, 0, 2] [0, 2, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Протестировать онлайн: https://repl.it/repls/PowerlessSeveralLeafbird