Built In Functions
Built in functions in Cyclone
Built In Functions
Cyclone provides a set of built-in functions that can be used to perform various operations. These functions are available to the user without the need for any import statements.
List of Built-in Functions
Cyclone provides the following built-in functions:
Utility Functions
The print function is used to print the value of the expression to the console.
print("Hello, World!")print only accepts a string as an argument. To print value other than string, you can use the string conversion function to convert the value to a string.
var a = 10
print(string(a))input
The input function is used to take input from the user.
print("Enter your name: ")
var name = input()
print("Hello, " + name)random
The random function is used to generate a random number between 0 and max.
var max : int = 10
var r = random(max)
print(r)size
The size function is used to get the size of the array.
var arr = [1, 2, 3, 4, 5]
var s = size(arr)
print(s)len
The len function is used to get the length of the string.
var s = "Hello, World!"
var l = len(s)
print(l)Conversion Functions
string
The string function is used to convert a value to a string.
var a = 10
var b = string(a)
print(b)
// "10"int
The int function is used to convert a value to an integer.
var a = 10.5
var b = int(a)
print(string(b))
// 10float
The float function is used to convert a value to a float.
var a : string = "10"
var b = float(a)
print(string(b))
// 10bool
The bool function is used to convert a value to a boolean.
var a = 10
var b = bool(a)
print(string(b))
// true