From e71eda7c5e9e96a90892fc2bc481649b671318a6 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Wed, 17 Jan 2018 17:13:53 +0000 Subject: [PATCH] Add check for negative number of iterations --- src/Lib.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Lib.hs b/src/Lib.hs index c52a003..a4d9ae5 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -43,6 +43,7 @@ iterateLSystem :: (Eq a, Integral t) => t -> LSystem a -> LSystem a iterateLSystem 0 lsystem = lsystem iterateLSystem n (LSystem a ax r ang dist rep) = iterateLSystem (n-1) $ LSystem a ax' r ang dist rep +iterateLSystem n lsystem | n < 0 = iterateLSystem (-n) lsystem where ax' = concat $ map f ax f x = case lookup x r of Just xs -> xs