Many languages pride themselves in having “batteries included”, meaning everything needed to use the language is provided. While we agree with this philosophy, we also want to minimize the complexity of large frameworks that come with languages like Python and Java. Having fewer choices means that it’s easier to learn, and our goal is to get you productive as quickly as possible. Consequently, Pez only supports a handful of data structures natively.

Before we talk about data structures, be sure you understand the basic types in pez.

Vectors

Vectors represent an ordered collection of things. If you are coming from Excel, you can think of a vector as being a contiguous range of cells. The elements of a vector can all be of the same type, such as a sequence of integers.

They can also be heterogeneous like a set.

Realistically, most of your vectors will be homogeneous, making them easier to work with. For numeric vectors, mixed algebraic operations work just like in linear algebra, where scalars are applied to all elements of a vector.

Data Frames

A data frame is a tabular data structure composed of many vectors. You can think of a data frame as being a table where each column is a vector. In Excel, a data frame is similar to a grid of cells. Thus it’s easy to see why all the vectors comprising the grid have equal length.

In the output, the left most column is the index. This tells you what index to use to extract an element from the data frame. The top row contains the column headers. If no information is provided, then it defaults to “X” followed by an index number. If you don’t like the default names, you can name them yourself when creating the data frame. Just like a table header, this can add extra information that is useful for someone using this object.

Indices

Both vectors and data frames support indices. When using a literal, simply assign the @index attribute within the literal. For a vector, this looks like

Element can then be accessed via ordinal index or label.