Skip to content

Instantly share code, notes, and snippets.

@jamesmcm
Created November 8, 2012 10:46
Show Gist options
  • Save jamesmcm/4038092 to your computer and use it in GitHub Desktop.
Save jamesmcm/4038092 to your computer and use it in GitHub Desktop.
First rosalind exercise in Haskell
import Control.Monad
import Data.Char
main = do
l <- getLine
putStrLn $ show ( foldr myfunction (0, 0, 0, 0) l)
myfunction :: Char -> (Integer, Integer, Integer, Integer) -> (Integer, Integer, Integer, Integer)
myfunction x (a,c,g,t)
| x=='A' = (a+1,c,g,t)
| x=='C' = (a,c+1,g,t)
| x=='G' = (a,c,g+1,t)
| x=='T' = (a,c,g,t+1)
| otherwise = (a,c,g,t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment