Objects

Composed data

We have five ways to compose data, inductive data, tuples, collections, arrays, and hashes.

Note that, a tuple that consists of a single element is equal with the element itself.

Note that we can splice collections using @ inside a collection.

Functions

lambda expressions make functions as other functional programming languages.

Matchers

We can define our own matcher using a matcher expression is used to define how to pattern-match for each data type. It's too complicated to explain here, so please read the manual for that.
The following matchers are defined in the core libraries. something is an only buitin matcher.

Syntax

Partial evaluation

We support partial evaluations.

let, let* and letrec expressions

A let and letrec expression are used for local variable bindings. The difference is that a letrec expression can used for recursive definitions. Mutual recursion is also allowed.

if expressions

It's ordinary if. But, note the result of an evaluation of the first argument must be a boolean value (i.e. #t or #f).

Pattern-Matching

cons,join, and nil

The cons pattern is used to divide a collection into a element and the rest of the collection.

The join pattern is used to divide a collection into two collections.

The nil pattern matches if a collection is empty.

Non-linear patterns

We can write non-linear patterns.

Loop-patterns

We can write a pattern that include ....

Modularization of patterns

We can reuse useful patterns with pattern-functions, functions that take patterns and return a pattern.

Builtin Functions

Please check here for the complete list of builtin functions.

Compare numbers

We can compare numbers using the eq?, gt?, lt?, gte?, and lte? function.

Strings

A string is a collection of characters in Egison. Therefore, we can use functions for collections to handle strings.

Libraries

Please check here for the Egison library list.

Collections

Please check here for the Egison collection library.

The nats is a collection that contains all natural numbers.
The primes is a collection that contains all prime numbers.
We can play with them. With the take function, we can extract a head part of the collection.

With the map function, we can operate each element of the collection at once.

With the foldl function, we can gather together all elements of the collection using an operator we like.

With the filter function, we can extract all elements that satisfy the predicate.

With the while function, we can extract all head elements that satisfy the predicate.

Programming Tips

Infinite collections

We can generate infinite collections recursively.

The results of match-all can be infinite.

This website in other langauge: English, 日本語