Emerald is an object oriented language that uses prototypal based inheritance.
git clone https://github.com/emeraldlang/emerald.git
cd emerald
mkdir build
cd build
conan install ..
cmake ..
make
The compile command will compile the specified source files and creates an .emc file.
./build/bin/emerald compile some_folder/some_file.em
The run command takes the name of the module you want to execute. It looks for
a .emc file so be sure to run the compile command before.
./build/bin/emerald run some_folder.some_file
import core
core.print('hello world')
def fib : n
return additive_sequence(n, 0, 1)
end
def additive_sequence : n, t0, t1
if (n == 0) return t0
if (n == 1) return t1
return additive_sequence(n - 1, t1, t0 + t1)
end
def collatz : n
let c = 1
while (n != 1) do
if (n % 2 == 0) then
n = n / 2
else
n = 3 * n + 1
end
c += 1
end
return c
end
let foo = {
name: 'foo',
one: 1,
two: 2
}
let bar = clone foo
bar.two = 'two'
bar.three = 3
bar.one # 1
bar.three # 3
bar.two # 'two'
bar.name # 'foo'
foo.name # 'foo'