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.
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.
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.
But, note the result of an evaluation of the first argument must be a boolean value (i.e.
cons pattern is used to divide a collection into a element and the rest of the collection.
join pattern is used to divide a collection into two collections.
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
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.
nats is a collection that contains all natural numbers.
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.
map function, we can operate each element of the collection at once.
foldl function, we can gather together all elements of the collection using an operator we like.
filter function, we can extract all elements that satisfy the predicate.
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.