Difference between revisions of "Cookbook/Interactivity"
< Cookbook
Jump to navigation
Jump to search
Line 27: | Line 27: | ||
|} |
|} |
||
+ | |||
− | == Printing a string == |
||
− | Strings can be output in a number of different ways. |
||
− | <haskell> |
||
− | Prelude> putStr "Foo" |
||
− | FooPrelude> |
||
− | </haskell> |
||
− | As you can see, [http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AputStr putStr] does not include the newline character `\n'. We can either use putStr like this: |
||
− | <haskell> |
||
− | Prelude> putStr "Foo\n" |
||
− | Foo |
||
− | </haskell> |
||
− | Or use [http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AputStrLn putStrLn], which is already in the Standard Prelude |
||
− | <haskell> |
||
− | Prelude> putStrLn "Foo" |
||
− | Foo |
||
− | </haskell> |
||
− | We can also use [http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Aprint print] to print a string, '''including the quotation marks.''' |
||
− | <haskell> |
||
− | Prelude> print "Foo" |
||
− | "Foo" |
||
− | </haskell> |
||
== Parsing command line arguments == |
== Parsing command line arguments == |