-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSum.hs
20 lines (18 loc) · 828 Bytes
/
Sum.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# LANGUAGE ParallelListComp #-}
module Sum
( getSums
) where
import Neighbour
import Control.Applicative
getSums :: [String] -> [[Int]]
getSums board = [getZipList $ (\a b c d e f g h -> a + b + c + d + e + f + g + h) <$>
ZipList r <*> ZipList l <*> ZipList t <*> ZipList b <*>
ZipList tr <*> ZipList tl <*> ZipList br <*> ZipList bl
| r <- stateOfAllRightNeighbours board
| l <- stateOfAllLeftNeighbours board
| t <- stateOfAllTopNeighbours board
| b <- stateOfAllBotNeighbours board
| tr <- stateOfAllTopRightNeighbours board
| tl <- stateOfAllTopLeftNeighbours board
| br <- stateOfAllBotRightNeighbours board
| bl <- stateOfAllBotLeftNeighbours board]