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

Java is Homoiconic

Name: Anonymous 2011-10-03 19:27

The language itself is the same over-engineered bullshit as the programs that are written in it.

Name: Anonymous 2011-10-04 13:39

>>39
C/C++:

  char *S;
again:
  S = readline("Insert your new password:");
  if (!isValid(S)) goto again; 
  printf("Storing in database...");


Haskell (http://en.wikibooks.org/wiki/Haskell/Monad_transformers):

newtype (Monad m) => MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) }

instance Monad m => Monad (MaybeT m) where
    return  = MaybeT . return . Just

instance Monad m => MonadPlus (MaybeT m) where
    mzero     = MaybeT $ return Nothing
    mplus x y = MaybeT $ do maybe_value <- runMaybeT x
                            case maybe_value of
                                 Nothing    -> runMaybeT y
                                 Just value -> runMaybeT x
 
instance MonadTrans MaybeT where
    lift = MaybeT . (liftM Just)



getValidPassword :: MaybeT IO String
getValidPassword = do s <- lift getLine
                      guard (isValid s)
                      return s
 
askPassword :: MaybeT IO ()
askPassword = do lift $ putStrLn "Insert your new password:"
                 value <- getValidPassword
                 lift $ putStrLn "Storing in database..."

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