Skip to content

Instantly share code, notes, and snippets.

@jamesmcm
Created November 8, 2012 16:55
Show Gist options
  • Save jamesmcm/4040041 to your computer and use it in GitHub Desktop.
Save jamesmcm/4040041 to your computer and use it in GitHub Desktop.
Rosalind 6 Haskell
import Data.List
import Char
main = do
l <- getContents
let l' = myToInt l
let list = getList l'
let perms = getPermutations list
putStrLn $ show (length perms)
printing perms
return ()
getPermutations :: [Integer] -> [[Integer]]
getPermutations x = permutations x
getList :: Integer -> [Integer]
getList 0 =[]
getList x = x:(getList (x-1))
myToInt :: [Char] -> Integer
myToInt x = read x :: Integer
printing :: [[Integer]] -> IO ()
printing [] = do
return ()
printing (x:xs) = do
let string = formString x
putStrLn string
let z = printing xs
seq z z
return ()
formString :: [Integer] -> String
formString [] = ""
formString (x:xs) = [chr((mytoint(x))+48)] ++ " " ++ formString(xs)
mytoint :: Integer -> Int
mytoint x = fromIntegral x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment