Inspired from Eloquent JS book! ツ
Egg is a general purpose high level mathematical and functional programming language created for fun built on top of JavaScript, it supports simple features like, bindings, scopes, functions, closure, recursive calls, if/while/do applications, comments, & basic arithmetic/comparison operations.
- Auto indent lines.
- Auto close parenthesis.
If you're declaring a variable for the first use the special form def
If you're changing an existing variable use the special form set
Done by using the special form do
Done by using ,
Done by using #
+
for addition.
-
for substraction.
*
for multiplication.
/
for division.
%
for remainder.
=
for checking equality.
<
to check if less than.
>
to check if greater than.
<=
to check if less or equal than.
>=
to check if greater or equal than.
!=
to check if not equal to.
Done by using the special form while
do(
def(total, 0),
def(count, 0),
while(<(count, 11),
do(
set(total, +(total, count)),
set(count, +(count, 1))
)
),
print(total) # → 55
)
Done by using the special form fun
do(
def(plusOne, fun(a, +(a, 1))),
print(plusOne(10)) # → 11
)
To make an array use the special form [].from
To get the length of an array use the special from [].len
To index a value in an array use the special from [].elem
do(
def(arr, [].from(1, 2, 3)),
print([].len(arr)), # → 3
print([].elem(arr, 1)) # → 2
)
See more projects - @devmotheg