YAIPL aims to be a dynamically typed language. Supported types are: Integer
, Float
, Boolean
, String
, Array
.
Keyword | Description |
---|---|
while | Loop through a block of code as long as a specified condition is true |
for | Loop through a block of code a specified number of times |
if | Execute a block of code if a specified condition is true |
return | Explicitly return a value |
Creating and reassigning variables is done using the =
operator.
# Assignining variables
my_variable = 5
# Reassigning variables
my_variable = 10
You can also create and REASSIGN functions using the =
operator.
# Defining a function
my_function = (param) {
param + 5 # Implicit return
}
# Reassigning a function
my_function = (param) {
param * 5
}
# Calling the function
print(my_function(5)) # returns 25
Function | Description | Returns |
---|---|---|
print(arg) | Prints the value of the argument to the console | "void" |
println(arg) | Same as print, but appends a '\n' at the end for a new line | "void" |
typeof(value) | Returns the type of the value | "int" | "float" | "bool" | "string" | "function" | "nfunction" | "void" |