Vorlesung 2

This commit is contained in:
Nicole Dresselhaus 2015-04-17 20:03:21 +02:00
parent f4e8d17e50
commit bcff353228
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
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))

BIN
lecture2.pdf Normal file

Binary file not shown.