Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I need to vent.

Name: Anonymous 2009-08-10 14:16

French C "programmers" who refuse to read K&R, and rely on some random "tutorials" in the internet. And yes, K&R *was* indeed translated to French as well, and as soon as that fact was pointed out to them, they switch the reason to "it's too complicated lol".

FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCKK.

Name: Anonymous 2009-08-13 1:26

>>68
You inspired me. How's this?

import Control.Monad
import Data.Char
import Data.IORef
import IO
import System

beer n = do
  mapM_ putStrLn $
    [bot n ++ otw, bot n, takeone, bot (n - 1) ++ otw ++ "\n"]
  if n == 1 then return () else beer (n - 1)
  where bot 0 = "No more bottles of beer"
        bot 1 = "One bottle of beer"
        bot x = show x ++ " bottles of beer"
        otw = " on the wall"
        takeone = if n == 0
                     then "Go to the store and buy some more"
                     else "Take one down and pass it around"

hello = putStrLn "Hello, world!"
quine src = putStrLn src
accum reg = modifyIORef reg (+1)

main = do
  args <- getArgs
  reg <- newIORef 0
  src <- if null args
            then hGetContents stdin
            else readFile $ head args
  forM_ src $ \c ->
    case toLower c of
      'h' -> hello
      'q' -> quine src
      '9' -> beer 99
      '+' -> accum reg
      _   -> return ()

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List