Various refactoring

This commit is contained in:
jgk
2021-08-17 19:08:18 +02:00
parent 807bc908d1
commit 9bdb9a227f
18 changed files with 313 additions and 191 deletions
+9 -3
View File
@@ -191,12 +191,18 @@ doublePair (x,y) = [(x,y),(y,x)]
doubleV2 :: V2 a -> [V2 a]
doubleV2 (V2 x y) = [V2 x y,V2 y x]
-- split a list into triples, forms triangles from a polygon
polyToTris :: [s] -> [s]
{-# INLINE polyToTris #-}
polyToTris (a:as) = go a as
polyToTris'' :: [s] -> [s]
polyToTris'' (a:as) = go a as
where
go !x (y:z:ys) = x : y : z : go x (z:ys)
go _ _ = []
polyToTris'' _ = []
polyToTris :: [s] -> [s]
{-# INLINABLE polyToTris #-}
polyToTris (x:xs) = foldr (f x) [] $ zip xs $ tail xs
where
f a (b,c) ls = a:b:c:ls
polyToTris _ = []
polyToTris' :: [s] -> [s]