on master help sign in
Fix bugs in Automaton discovered by Jeff
commit5c1089a77bcb74e0527365f412d32cba110fae7e authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateSun 23 Jun 2013, 16:36 (13 years ago) parent0d41af8
1 file changed+3−1
libraries/Automaton.elm+3−1
libraries/Automaton.elm+3−1
@@ -5,6 +5,8 @@
55module Automaton where
66
77import Signal (lift,foldp)
8+import List (reverse)
9+import Maybe (Just, Nothing)
810
911data Automaton a b = Step (a -> (Automaton a b, b))
1012
@@ -69,7 +71,7 @@ empty = ([],[])
6971enqueue x (en,de) = (x::en, de)
7072dequeue q = case q of
7173 ([],[]) -> Nothing
72− (en,[]) -> enqueue ([], reverse en)
74+ (en,[]) -> dequeue ([], reverse en)
7375 (en,hd::tl) -> Just (hd, (en,tl))
7476
7577-- Computes the running average of the last `n` inputs.