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

Problem w/ FP

Name: Anonymous 2012-02-09 22:49

Functional programing makes simple things nearly imposible to do . for example I found this exercise on reddit

"create a program that will ask the users name, age, and reddit username. have it tell them the information back, in the format:
your name is (blank), you are (blank) years old, and your username is (blank)
for extra credit, have the program log this information in a file to be accessed later."

At first I dismissed it as stupidly trivial but then thought, is there even a way to do this in scheme? And I couldnt think of one. This just shows that scheme sucks for programs used by users. There is no sequential steps to actually accomplish anything

Name: Anonymous 2012-02-10 0:23

Functional programing makes simple things nearly imposible to do .
I'm sure you are completely qualified to make that statement.

is there even a way to do this in scheme?
You're trolling, right? Of course it's possible in Scheme, Scheme isn't even purely functional.

And I couldnt think of one.
That's not Scheme's fault, it's yours.

Here's a solution in Haskell, which is purely functional:
import Control.Monad

main :: IO ()
main = do putStrLn "What is your name?"
          name <- getLine
          putStrLn "What is your age?"
          age <- readLn
          when (age > 12) $ error "stop lying, ``faggot''"
          putStrLn $ "Your name is " ++ name ++ ", you are " ++ show age ++
                     " years old and you are a massive faggot."


IHBT.

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