Difference between revisions of "Cookbook/Interactivity"
< Cookbook
Jump to navigation
Jump to search
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | == Input and output == |
||
+ | |||
{| class="wikitable" |
{| class="wikitable" |
||
|- |
|- |
||
Line 5: | Line 7: | ||
! Examples |
! Examples |
||
|- |
|- |
||
− | | |
+ | | printing a string |
− | | [http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v% |
+ | | [http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AputStr putStr] |
|<haskell> |
|<haskell> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
− | Strings can be output in a number of different ways. |
||
⚫ | |||
Prelude> putStr "Foo" |
Prelude> putStr "Foo" |
||
FooPrelude> |
FooPrelude> |
||
</haskell> |
</haskell> |
||
+ | |- |
||
⚫ | |||
+ | | printing a string with a newline character |
||
− | <haskell> |
||
⚫ | |||
− | Prelude> putStr "Foo\n" |
||
⚫ | |||
− | Foo |
||
− | </haskell> |
||
⚫ | |||
− | <haskell> |
||
Prelude> putStrLn "Foo" |
Prelude> putStrLn "Foo" |
||
Foo |
Foo |
||
+ | Prelude> |
||
</haskell> |
</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> |
</haskell> |
||
⚫ | |||
+ | |||
+ | |||
== Parsing command line arguments == |
== Parsing command line arguments == |