Documentation

Getting Started
Downloading Installing Launching
My First Chick
Egg Grammar
Literals Functions Classes Conditionals Loops Types Errors
Hatchery
Creating .egg Files Opening .egg Files Configuring the Hatchery Themes
Incubator
How to Incubate From Command Line Coming Soon
Example Projects
Language Packs
Options

Example Projects

Fibonacci Sequence Generator: Count is the number of fib numbers to generate, and they are printed to the console when the fibonacci() function is called.

VAR num1 = 0
VAR num2 = 1
VAR num3 = 0
VAR count = 10
VAR i = 0

DEF fibonacci(){
IF(num3 == 0)
{
    print(toString(num1))
}

LOOP(i = 0, i < count, i = i + 1){
    num3 = num1 + num2
    print(" " + toString(num3))
    num1 = num2
    num2 = num3
    }
}

fibonacci()

Output: 0 1 2 3 5 8 13 21 34 55 89

Pascal's Triangle Generator: Creates a triangular array of binomial coefficients.

VAR num = 0
VAR i = 0
VAR line = 0

//Prints the first n lines of the triangle.
DEF printPascal(n){

    //Iterate through each line and print entries
    LOOP(line = 0, line < n, line = line + 1){

        //Every line has number of nums equal to line number
        LOOP(i = 0, i <= line, i = i + 1){
            print(toString(binomCoeff(line, i)) + " ")
            print(" ")
        }
        print("\n")
    }

}

DEF binomCoeff(n, k){
    VAR res = 1

    IF(k > (n - k)){
        k = n - k
    }

    VAR j = 0

    LOOP(j = 0, j < k, j = j + 1){
        res = res * (n - j)
        res = res / (j + 1)
    }

    RETURN res
}

VAR number = 7

printPascal(number)

Output:

1
1  1
1  2  1
1  3  3  1
1  4  6  4  1
1  5  10  10  5  1
1  6  15  20  15  6  1