Skip to content
Snippets Groups Projects
Commit bcff3532 authored by Nicole Dresselhaus's avatar Nicole Dresselhaus
Browse files

Vorlesung 2

parent f4e8d17e
No related branches found
No related tags found
No related merge requests found
module Main where
{- Hier eine Passende Definition der State-Monade einfügen... -}
{- z.B. Control.Monad.Trans.State aus dem transformers-package -}
{- oder Control.Monad.State aus dem veralteten mtl-package -}
type CountState = (Bool, Int)
startState :: CountState
startState = (False, 0)
play :: String -> State CountState Int
play [] = do
(_, score) <- get
return score
play (x:xs) = do
(on, score) <- get
case x of
'C' -> if on then put (on, score + 1) else put (on, score)
'A' -> if on then put (on, score - 1) else put (on, score)
'T' -> put (False, score)
'G' -> put (True, score)
_ -> put (on, score)
play xs
main = print $ runState (play "GACAACTCGAAT") startState
-- -> (-3,(False,-3))
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment