Advertisement
Guest User

haskell quine

a guest
Oct 25th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/runhaskell
  2.  
  3.  
  4. scode = [ "#!/usr/bin/runhaskell"
  5.         , ""
  6.         , ""
  7.         , "scode = [ "
  8.         , ""
  9.         , ""
  10.         , "backslash = "
  11.         , "quote = "
  12.         , "indent = "
  13.         , "commasp = "
  14.         , "spbracket = "
  15.         , ""
  16.         , ""
  17.         , "main = do"
  18.         , "    foldl1 (>>) (map putStrLn (take 3 scode))"
  19.         , "    putStrLn ((scode !! 3) ++ quote ++ (scode !! 0) ++ quote)"
  20.         , "    foldl1 (>>) (map (putStrLn . ((indent ++ commasp ++ quote) ++) . (++ quote)) (init . tail $ scode))"
  21.         , "    putStrLn (indent ++ commasp ++ quote ++ (last scode) ++ quote ++ spbracket)"
  22.         , "    foldl1 (>>) (map putStrLn ((drop 4) . (take 6) $ scode))"
  23.         , "    putStrLn ((scode !! 6) ++ quote ++ backslash ++ backslash ++ quote)"
  24.         , "    putStrLn ((scode !! 7) ++ quote ++ backslash ++ quote ++ quote)"
  25.         , "    putStrLn ((scode !! 8) ++ quote ++ indent ++ quote)"
  26.         , "    putStrLn ((scode !! 9) ++ quote ++ commasp ++ quote)"
  27.         , "    putStrLn ((scode !! 10) ++ quote ++ spbracket ++ quote)"
  28.         , "    foldl1 (>>) (map putStrLn (drop 11 scode))" ]
  29.  
  30.  
  31. backslash = "\\"
  32. quote = "\""
  33. indent = "        "
  34. commasp = ", "
  35. spbracket = " ]"
  36.  
  37.  
  38. main = do
  39.     foldl1 (>>) (map putStrLn (take 3 scode))
  40.     putStrLn ((scode !! 3) ++ quote ++ (scode !! 0) ++ quote)
  41.     foldl1 (>>) (map (putStrLn . ((indent ++ commasp ++ quote) ++) . (++ quote)) (init . tail $ scode))
  42.     putStrLn (indent ++ commasp ++ quote ++ (last scode) ++ quote ++ spbracket)
  43.     foldl1 (>>) (map putStrLn ((drop 4) . (take 6) $ scode))
  44.     putStrLn ((scode !! 6) ++ quote ++ backslash ++ backslash ++ quote)
  45.     putStrLn ((scode !! 7) ++ quote ++ backslash ++ quote ++ quote)
  46.     putStrLn ((scode !! 8) ++ quote ++ indent ++ quote)
  47.     putStrLn ((scode !! 9) ++ quote ++ commasp ++ quote)
  48.     putStrLn ((scode !! 10) ++ quote ++ spbracket ++ quote)
  49.     foldl1 (>>) (map putStrLn (drop 11 scode))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement