Basic Code example

In this example, we'll walk through a simple "Gomelan" code snippet and explain its key features. "Gomelan" is designed to be easy to understand and use, making it a great choice for various programming tasks.

fn multiply(a: Int, b: Int) -> Int;

fn main() -> Int
{
    args: [String] = ["3", "10"];
    a: Int;
    b: Int;
    result: Int;

    for (i: Int = 0 ; i < len(args); i++) {
        a = stringToInt(arg[i]);
        b = stringToInt(arg[i]) + 10;
        result = multiply(a, b);
    }
    return result;
}

fn multiply(a: Int, b: Int) -> Int
{
    result: Int = a * b;
    return result;
}

Output:

30

This code snippet demonstrates several features of "Gomelan," including:

  1. Add prototype of function to use.

  2. Function definitions with parameter types and return types.

  3. Variable declaration and initialization.

  4. A loop to iterate over command line arguments.

  5. Basic arithmetic operations and function calls.

Last updated