vec p q = zipWith (-) q p add p v = zipWith (+) p v mul u v = map (u*) v dot v w = sum $ zipWith (*) v w sqd v = dot v v len v = sqrt $ sqd v dir v = [x/l|let l=len v,l>0,x<-v] rot [u,v,w] [x,y,z] = [v*z-w*y, w*x-u*z, u*y-v*x] tra = [[[-1,0,0],[0,0,0],[sqrt 0.75,0.5,0]], [[-1,0,0],[0,0,0],[-sqrt 0.75,0.5,0]], [[-sqrt 0.75,0.5,0],[0,0,0],[-1,0,0]]] tri t = [[b,c,add d (mul s e)]| [a,b,c]<-t, let d=add c (mul 0.5 (dir (vec b c))), let e=dir (rot (vec a b) (vec b c)), s<-mul (sqrt 0.75) [-1,1]] main = putStrLn $ unlines $ map show $ concat $ concat $ take 12 $ iterate tri tra