chapter four

4 Julia as a spreadsheet

 

This chapter covers

  • Working with collections of numbers using the Array and Tuple` types
  • Useful types to put into collections such as numbers, characters and text strings
  • Performing statistics
  • Transforming lists of numbers with map
  • Using predicates with the filter function

In the second chapter we discussed how to work with Julia as a calculator. However people working with numbers today, don’t usually use desk calculators. They use spreadsheet tools such as Microsoft Excel or Apple Numbers.

In these applications numbers are stored in tables. We work with whole columns of numbers. All serious scientific work involves working with large tables of data. Scientists and data analysts get survey data or measurements they want to analyze. Julia is excellent for this type of work. However we will only scratch the surface of what is possible to do in this chapter. Instead the main purpose is to introduce the Array and Tuple datatypes. Because these are containers for other values, we will also touch upon the Char (character) and String (text string) types to have something interesting to put in our arrays and tuples.

In fact we are going to put numbers, characters, text strings and Boolean values into these two collection types.

Figure 4.1. Apple Numbers, a spreadsheet application for working with rows and columns of numbers.
apple numbers

4.1 Analyzing pizza sales

4.2 Different types of arrays

4.3 Performing operations on arrays

4.4 Working with the statistics module

4.5 Accessing elements

4.6 Creating arrays

4.7 Mapping values in an array

4.8 Introducing characters and strings

4.9 Storing pizza data in tuples

4.10 Filter pizzas based on predicates

4.10.1 Combining higher order functions

4.11 Mapping and reducing an array

4.13 Summary