Personal tools  Haskell Quiz/Geodesic Dome Faces/Solution
Jkramar  From HaskellWiki  Jump to: navigation, search  This
problem seems to be strongly IO-bound, so actually computing the
geodesic faces is not too time-sensitive. Hence there is time
for computing the faces from the vertices by trying each triple
of vertices to check if it's a face.  Originally I wrote this
program representing vectors just by ordinary tuples, and in
some places that was definitely more understandable. But of
course it's more fun this way.  import Prelude hiding (maximum,
foldr, foldr1, concat, sequence_, sum) import Control.Monad
hiding (sequence_) import Control.Applicative import
Data.Foldable data V3 a = V !a !a !a deriving (Read,Show)
instance Foldable V3 where foldr f x (V a b c) = f a$f b$f c x
instance Functor V3 where fmap f (V a b c) = V (f a) (f b) (f c)
instance Applicative V3 where   pure a = V a a a   V f g h <*> V
a b c = V (f a) (g b) (h c) type Tri a = V3 (V3 a) (.+) :: (Num
a) => V3 a -> V3 a -> V3 a (.+) = liftA