Pez is designed for data analysis. It is functional in nature, has consistent semantics across data structures, and most importantly, is easy to learn.

## Basic Syntax

### Identifiers

Start with an underscore or a letter, followed by any alphanumeric character plus underscore.

1 2 3 4 |
!pez x = "hello" hello !pez x_1 = 3 3 |

## Primitive Types

Pez supports characters and numbers. No distinction is made between integers and floating point numbers.

1 2 |
!pez 4 + 2.1 6.1 |

See Primitive Types for more information.

## Lists

Create lists using square brackets: [1, 2, 3, 4]. The same list can be created using sequence notation: 1..4. Lists in pez are heterogeneous (like R lists but not vectors), so [1, 'a', [2,3]] is valid.

To get the length of a list, use the length function, such as length([1,2,3]). If the list is assigned to a variable, x = 1..4, then bar notation can be used: |x|.

See Data Structures for more information.

## Data Frames

See Data Structures for more information.

## Functions

Functions are the basis of computation in pez.

### Defining functions

Function definition follows ML syntax. Use the keyword fn followed by the argument list, separated by white space. All functions are lambda abstractions and are limited to one expression, which is separated from the argument list with a colon.

1 |
fn a b: a + b |

While it may seem limiting to require single expressions, this has the consequence of simplifying functions. There is, however, a way to write multiline functions, and that is with a let expression, discussed later.

### Applying functions

All functions are anonymous, so to use them they need to be bound to a variable.

1 2 |
!pez f = fn a b: (a^2 + b^2)^.5 <function closure at 0x7f4b301692a8> |

Once it is bound to a variable, the function can be applied to an argument list in one of two ways. Like ML, no parentheses are necessary, so the simplest function application is simply the function followed by its arguments.

1 2 |
!pez f 3 4 5.0 |

Alternatively, the arguments can be wrapped in parentheses and separated by commas.

1 2 |
!pez f(3,4) 5.0 |

### Composing functions

1 |
f . g |

1 |
map f . g [1,2,3] |

See Functions for more information.