This chapter covers
- Representing text with the
String
type
- Formatting text with
lpad
andrpad
- Reading text from a keyboard or a file
- Writing text to the screen or a file
- Creating a simple interactive program
This chapter will focus on practical aspects of working with text in Julia, such has how do you show text on the screen, read or write it to a file. We will also look at simple interactive application where the user writes responses to questions.
However first we will focus on different ways of displaying text on the screen. We will revisit our our pizza sales and sine table examples. The tables we created before was not very readable. How about creating a neat display like this?
Here sine and cosine values are neatly arranged in separate columns. Likewise would it not be better to neatly organize information about pizza sales into clearly separated columns, as seen below?
We will start by looking at the final result. The code we want to write, and then work our way backwards to explain how we got there. The code should not be entirely alien, but there are some new concepts which we need to explain.