Skip to content

Instantly share code, notes, and snippets.

@AnthonyMikh
Created January 26, 2018 18:26
Show Gist options
  • Save AnthonyMikh/67c587a75ed1d8a94e60a47c0789d56c to your computer and use it in GitHub Desktop.
Save AnthonyMikh/67c587a75ed1d8a94e60a47c0789d56c to your computer and use it in GitHub Desktop.
Решение задачи №65 от UniLecs (вариант со списками)
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]
@AnthonyMikh
Copy link
Author

Протестировать онлайн: https://repl.it/repls/PowerlessSeveralLeafbird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment