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:
Add prototype of function to use.
Function definitions with parameter types and return types.
Variable declaration and initialization.
A loop to iterate over command line arguments.
Basic arithmetic operations and function calls.
Last updated
Was this helpful?