define and test expressionsload and load-file expressionsWe 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.
lambda expressions make functions as other functional programming languages.
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.
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).
match-all expressionsmatch expressionscons,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.
We can write non-linear patterns.
We can write a pattern that include ....
We can reuse useful patterns with pattern-functions, functions that take patterns and return a pattern.
Please check here for the complete list of builtin functions.
We can compare numbers using the eq?, gt?, lt?, gte?, and lte? function.
A string is a collection of characters in Egison. Therefore, we can use functions for collections to handle strings.
Please check here for the Egison library list.
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.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.
We can generate infinite collections recursively.
The results of match-all can be infinite.