Permalink
Browse files

efficiency

  • Loading branch information...
1 parent 20f98d1 commit 33d8d068f54de5b828e2e7a74cbf50bdfaf9cd18 alex committed Mar 13, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 Pattern.hs
View
@@ -67,12 +67,9 @@ class Patternable p where
instance Patternable [] where
toPattern xs = Cycle ps
where
- ps = map (\x -> Arc {pattern = Atom $ xs !! x,
- onset = (fromIntegral x) /
- (fromIntegral $ length xs),
- duration = Nothing
- }
- ) [0 .. (length xs) - 1]
+ n = length xs
+ ps = zipWith mkArc xs [0..]
+ mkArc x i = Arc (Atom x) ((fromIntegral i) / (fromIntegral n)) Nothing
{-size :: Pattern a -> Double
size (Atom {}) = 1

0 comments on commit 33d8d06

Please sign in to comment.