Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getClusterPositions :: Int -> Int -> [Elem] -> [Int]
- getClusterPositions _ _ [] = []
- getClusterPositions occur pos (Dot:Star:t)
- | occur == countStarSeq (Star:t) = (pos+1) : getClusterPositions occur (pos+2) t
- | otherwise = getClusterPositions occur (pos+2) t
- getClusterPositions occur pos (_:t) = getClusterPositions occur (pos+1) t
- removeCluster :: Int -> Int -> [Elem] -> [Elem]
- removeCluster _ _ [] = []
- removeCluster occur _ (Dot:t) = Dot:removeCluster occur 0 t
- removeCluster occur index (Star:t)
- | (index + countStarSeq (Star:t)) == occur = Dot:(removeCluster occur (index+1) t)
- | otherwise = Star:(removeCluster occur (index+1) t)
- occ :: [Elem] -> [(Int, [Int])]
- occ x
- | countStar x > 0 = (countStarSeq x, getClusterPositions (countStarSeq x) 0 (Dot:x)) : occ (removeCluster (countStarSeq x) 0 x)
- | otherwise = []
- countStarSeq :: [Elem] -> Int
- countStarSeq [] = 0
- countStarSeq (Star:Dot:t) = 1
- countStarSeq (Star:t) = 1 + countStarSeq t
- countStarSeq (Dot:t) = countStarSeq t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement