diff options
author | Ben Sima <ben@bsima.me> | 2018-06-30 10:15:19 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2018-06-30 10:15:19 -0700 |
commit | 0f79cf34d676b93bd51014f1753877d2ef61de5b (patch) | |
tree | 6b8a9e5e47b28aa5c55cf05ea10438b7c21f2f56 /simspace/Main.hs | |
parent | e2e345520ca8ffcaece19d27007e87dcfa02d864 (diff) |
Add type sigs and try to fix bug
Diffstat (limited to 'simspace/Main.hs')
-rw-r--r-- | simspace/Main.hs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/simspace/Main.hs b/simspace/Main.hs index 229bba4..18f744a 100644 --- a/simspace/Main.hs +++ b/simspace/Main.hs @@ -34,12 +34,15 @@ takeWhile' p (x:xs) = x : if p x then takeWhile' p xs else [] compute :: Int -> [Int] -> [Int] compute n state = state ++ compute n (next n state) +next :: Int -> [Int] -> [Int] next n state = [left, center, right] where - center = translate $ getLast n state - right = translate $ getLast (n+1) state - left = translate $ getLast (n-1) state + center = translate $ getLast n' state + right = translate $ getLast (n'+1) state + left = translate $ getLast (n'-1) state + n' = n+n +getLast :: Int -> [a] -> [a] getLast n ls = drop (length ls - n) ls translate [0,0,0] = 0 |