Skip to content

Instantly share code, notes, and snippets.

@netzwerg
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netzwerg/dca85a8410865b833c3e to your computer and use it in GitHub Desktop.
Save netzwerg/dca85a8410865b833c3e to your computer and use it in GitHub Desktop.
Behavior of putStr regarding line termination (Haskell vs. Frege vs. Java)
module Print where
-- Identical to the Haskell version (Print.hs)
-- Frege doesn't print line 7 (even a manual stdout.flush afterwards doesn't work)
main = do
putStrLn "A line with line termination"
putStr "A line without line termination, e.g. to prompt for input: "
line <- getLine
putStrLn ("You entered: " ++ line)
module Print where
main = do
putStrLn "A line with line termination"
putStr "A line without line termination, e.g. to prompt for input: "
line <- getLine
putStrLn ("You entered: " ++ line)
class Print {
public static void main(String[] args) {
System.out.println("A line with line termination");
System.out.print("A line without line termination, e.g. to prompt for input: ");
String line = new java.util.Scanner(System.in).nextLine();
System.out.println("You entered: " + line);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment