GLaDOS
  • Home
  • 🌴Introduction
    • Installation
    • Basic Code example
    • Syntax Overview
  • 🤖Developpers
    • Parsing
    • Verbose Mode
  • ✨Features
    • Types
    • Operators
    • Lists
    • Includes
    • Syntactic Sugar
    • Loops
    • Conditions
    • Internal Functions
    • Recursivity
    • Prototypes
    • Error handling
    • Comments
    • Scopes
  • 📚Libraries
    • Mathematics
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Features

Prototypes

GoMelan supports prototypes, like in C, when you have to use a function that is declare under the use calling function, you have to declare it above. If you do not, the script will not compile.

fn power(x: Int, y: Int) -> Int;

fn main() -> Int
{
    total: Float = 3.4;
    a: [Int] = [1, 3, -4, 2, 0, 6, -6];

    return power(floatToInt(total) + sum(a), 3);
}

fn power(x: Int, y: Int) -> Int
{
    if (x == 0) {
         return 0;
    }
    if (y < 0) {
        return (power(x, y – 1) / x);
    }
    return (power(x, y – 1) * x);
}

Output:

2197
  1. Declare the main function.

  2. Declare the power function.

  3. Paste the prototype above the main function.

PreviousRecursivityNextError handling

Last updated 1 year ago

Was this helpful?

✨