file.is_closed()
+
That's it! You now know how to read and write files in Radon.
diff --git a/search/search_index.json b/search/search_index.json
index bf46d2e..88433c5 100644
--- a/search/search_index.json
+++ b/search/search_index.json
@@ -1 +1 @@
-{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"index.html","title":"The Radon Programming Language","text":"Radon is a programming language that is designed to be easy to learn and use. Maintained by Md. Almas Ali
Website: https://radon-project.github.io
Documentation: https://radon-project.github.io/docs
Github: https://github.com/radon-project/radon
"},{"location":"index.html#introduction","title":"Introduction","text":"Radon is a programming language that is designed to be easy to learn and use. It is a high-level language intended to be used for general purpose programming. It is designed to be easy to learn and use, while still being powerful enough to be used for most tasks.
Some of the features of Radon include:
- A simple syntax that is easy to learn and use
- Dynamic typing so that you don't have to worry about types
- Powerful standard library that makes it easy to do common tasks (Development)
- Easy to use package manager that makes it easy to install packages (Future feature)
- Functional programming support
- Object-oriented programming support (Development)
- Easy to use concurrency support (Future feature)
- Easy to use GUI library (Future feature)
- Easy to use web development library (Future feature)
- Advanced command line interface (Development)
- Easy to use networking library (Future feature)
- Easy to use database library (Future feature)
- Easy to use graphics library (Future feature)
"},{"location":"index.html#login-logic","title":"Login Logic","text":"Login.rn# This is a Radon test file for the Radon Programming Language.\n\nclass Network {\n fun __constructor__(username, password) {\n this.username = username\n this.password = password\n }\n\n fun login() {\n if this.username == \"radon\" {\n if this.password == \"password\" {\n print(\"Log in successful\")\n }\n } else {\n print(\"Invalid credentials\")\n }\n }\n}\n\nusername = input(\"Enter you username: \")\npassword = input(\"Enter your password: \")\n\nnetwork = Network(username, password)\nnetwork.login()\n
"},{"location":"index.html#sponsors","title":"Sponsors","text":"No sponsors yet. Be the first one to sponsor this project. Become a sponsor
"},{"location":"arrays.html","title":"Arrays","text":""},{"location":"arrays.html#built-in-array-methods","title":"Built-in Array methods","text":" arr_len()
or len(arr)
- returns the length of the array arr_push(array, item)
- adds an item to the end of the array arr_pop(array, index)
- removes an item from the end of the array arr_append(array, item)
- adds an item to the end of the array arr_extend(array1, array2)
- adds all the items of an array to the end of the array arr_find(array, index)
- returns the item at the specified index arr_slice(array, start, end)
- returns the items from the specified start index to the specified end index
methods.rnarr = [1, 2, 3, 4, 5]\nprint(arr_len(arr)) # 5\n\narr_push(arr, 6)\nprint(arr) # [1, 2, 3, 4, 5, 6]\n\narr_pop(arr)\nprint(arr) # [1, 2, 3, 4, 5]\n\narr_append(arr, 6)\nprint(arr) # [1, 2, 3, 4, 5, 6]\n\narr_extend(arr, [7, 8, 9])\nprint(arr) # [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nprint(arr_find(arr, 0)) # 1\nprint(arr_find(arr, 1)) # 2\n\nprint(arr_slice(arr, 0, 5)) # [1, 2, 3, 4, 5]\n
"},{"location":"arrays.html#array-operators","title":"Array operators","text":" +
(concatenation) *
(repetition)
operators.rnarr1 = [1, 2, 3]\narr2 = [4, 5, 6]\n\nprint(arr1 + arr2) # [1, 2, 3, 4, 5, 6]\nprint(arr1 * 2) # [1, 2, 3, 1, 2, 3]\n
"},{"location":"arrays.html#array-standard-library","title":"Array standard library","text":" map(func)
- returns a new array with the result of calling the specified function on each item of the array append(item)
- adds an item to the end of the array pop(index)
- removes an item from the end of the array extend(list)
- adds all the items of an array to the end of the array find(index)
- returns the item at the specified index slice(start, end)
- returns the items from the specified start index to the specified end index len()
- returns the length of the array is_empty()
- returns true
if the array is empty, otherwise false
to_string()
- returns the string representation of the array is_array()
- returns true
if the value is an array, otherwise false
array-standard-library.rnimport Array # Include the Array standard library\n\n# Create an array instance using the Array class\narr = Array([1, 2, 3, 4, 5])\n\nprint(len(arr)) # 5\nprint(arr.is_empty()) # false\nprint(arr.to_string()) # \"[1, 2, 3, 4, 5]\"\nprint(arr.is_array()) # true\n\nprint(arr.map(fun (item) -> str(item))) # [\"1\", \"2\", \"3\", \"4\", \"5\"]\n\nprint(arr.append(6)) # [1, 2, 3, 4, 5, 6]\nprint(arr.pop(5)) # [1, 2, 3, 4, 5]\n\nprint(arr.extend([6, 7, 8])) # [1, 2, 3, 4, 5, 6, 7, 8]\nprint(arr.find(0)) # 1\nprint(arr.find(1)) # 2\n\nprint(arr.slice(0, 5)) # [1, 2, 3, 4, 5]\n
"},{"location":"built-in-functions.html","title":"Built-in Functions","text":""},{"location":"built-in-functions.html#types-of-built-in-functions","title":"Types of built-in functions","text":"Built-in functions are the functions that are built into the language. They are used to perform common tasks. In Radon, there are a list of built-in functions that are available to use.
They are:
"},{"location":"built-in-functions.html#utility-methods","title":"Utility methods","text":" cls()
- clears the screen. clear()
- clears the screen. exit()
- exits the program.
"},{"location":"built-in-functions.html#shell-commands","title":"Shell commands","text":" help(obj)
- get help about any object license()
- show project license credits()
- show project credits
"},{"location":"built-in-functions.html#same-as-import-statement","title":"Same as import
statement","text":" require()
- same as include statement to include a file or library in the current program.
"},{"location":"built-in-functions.html#command-line-arguments","title":"Command line arguments","text":" sys_args()
- returns the command line arguments.
"},{"location":"built-in-functions.html#api-methods","title":"API methods","text":" pyapi(string,ns)
- A high-level Python API for Radon. It is used to call Python functions from Radon.
"},{"location":"built-in-functions.html#typecase-methods","title":"Typecase methods","text":" int()
- converts any value to an integer. float()
- converts any value to a float. str()
- converts any value to a string. bool()
- converts any value to a boolean. type()
- returns the type of the value.
"},{"location":"built-in-functions.html#type-checker-methods","title":"Type checker methods","text":" is_num()
- returns true
if the value is a number, otherwise false
. is_int()
- returns true
if the value is an integer, otherwise false
. is_float()
- returns true
if the value is a float, otherwise false
. is_str()
- returns true
if the value is a string, otherwise false
. is_bool()
- returns true
if the value is a boolean, otherwise false
. is_array()
- returns true
if the value is an array, otherwise false
. is_fun()
- returns true
if the value is a function, otherwise false
.
"},{"location":"built-in-functions.html#string-methods","title":"String methods","text":" str_len()
- returns the length of the string. str_find(string, index)
- returns the character at the specified index. str_slice(string, start, end)
- returns the substring from the specified start index to the specified end index.
"},{"location":"built-in-functions.html#io-methods","title":"I/O methods","text":" print()
- prints the specified value to the console. print_ret()
- prints the specified value to the console and returns the value. input()
- reads a line from the console. input_int()
- reads an integer from the console.
"},{"location":"built-in-functions.html#array-methods","title":"Array methods","text":" arr_len()
- returns the length of the array. arr_push(array, item)
- adds an item to the end of the array. arr_pop(array, index)
- removes an item from the end of the array. arr_append(array, item)
- adds an item to the end of the array. arr_extend(array1, array2)
- adds all the items of an array to the end of the array. arr_find(array, index)
- returns the item at the specified index. arr_slice(array, start, end)
- returns the items from the specified start index to the specified end index.
"},{"location":"classes.html","title":"Classes and Objects","text":""},{"location":"classes.html#object-oriented-programming","title":"Object Oriented Programming","text":"Object Oriented Programming (OOP) is a programming paradigm that uses objects and their interactions to design and program applications. It is based on the concept of objects rather than just functions and procedures. These objects are organized into classes, which allow individual objects to be grouped together. Most modern programming languages including Java, C/C++, and Python are object-oriented languages, and many older programming languages now have object-oriented versions.
In Radon, we also have support for OOP. We can create classes and objects. We can also create methods and fields.
"},{"location":"classes.html#classes","title":"Classes","text":"Let's start by creating a class. We can create a class using the class
keyword. It is followed by the name of the class and the body of the class. The body of the class is enclosed in curly braces.
classes.rnclass Person {\n # Class body\n}\n
"},{"location":"classes.html#objects","title":"Objects","text":"Now that we have created a class, we can create an object. We can create an object by simply calling the class like as a function. It is followed by the name of the class and the arguments in parentheses. The arguments are optional.
objects.rnperson = Person()\n
"},{"location":"classes.html#fields","title":"Fields","text":"Fields are the variables that are declared inside a class. They are used to store data. They are also called instance variables because they are unique to each instance of the class. They are declared using the var
keyword. It is followed by the name of the field and the type of the field. The type of the field is optional.
fields.rnclass Person {\n name = \"John\"\n age = 20\n}\n
"},{"location":"classes.html#constructors","title":"Constructors","text":"Constructors are special methods that are used to initialize the fields of a class. They are called when an object is created. They are declared using the fun
keyword. It is followed by the name (class name) of the constructor and the parameters in parentheses. The parameters are optional.
constructors.rnclass Person {\n fun Person(name, age) {\n this.name = name\n this.age = age\n }\n}\n\nperson = Person(\"John\", 20)\n
"},{"location":"classes.html#methods","title":"Methods","text":"Methods are the functions that are declared inside a class. They are used to define the behavior of the class. They are declared using the fun
keyword. It is followed by the name of the method, the parameters in parentheses, and the return type. The parameters and the return type are optional.
methods.rnclass Person {\n fun __constructor__(name, age) {\n this.name = name\n this.age = age\n }\n\n fun say_hello() {\n print(\"Hello, \" + this.name + \"!\")\n }\n}\n\nperson = Person(\"John\", 20)\nperson.say_hello() # Output: Hello, John!\n
"},{"location":"contribution.html","title":"Contribution","text":""},{"location":"contribution.html#how-to-contribute","title":"How to contribute","text":"We need contributors to help us build the language. If you are interested, please make contributions to the radon-project/radon
repository.
Steps to contribute:
- Fork the repository.
- Clone the repository.
- Create a new branch.
- Make changes.
- Commit changes.
- Push to the branch.
- Create a pull request.
Before making a pull request create an issue and discuss the changes you want to make. If you have any questions, feel free to ask in the issues section.
"},{"location":"control-flow.html","title":"Control flow","text":""},{"location":"control-flow.html#conditional-statements","title":"Conditional statements","text":"Conditional statements are used to execute code based on a condition. In Rain, the if
statement is used to execute code if a condition is true. The else
statement is used to execute code if the condition is false. The elif
statement is used to execute code if the condition is false and another condition is true. The else
statement is optional.
conditional-statements.rnif true {\n print(\"true\")\n\n} else {\n print(\"false\")\n}\n
conditional-statements.rnif true {\n print(\"true\")\n\n} elif false {\n print(\"false\")\n\n} else {\n print(\"neither\")\n}\n
"},{"location":"data-types.html","title":"Data types","text":""},{"location":"data-types.html#basic-types","title":"Basic types","text":"The basic types are:
int
- integer number. float
- floating point number. bool
- boolean value. string
- string of characters.
"},{"location":"data-types.html#arrays","title":"Arrays","text":"Arrays are declared using the []
syntax. The type of the array is the type of the elements it contains.
arrays.rna = [1, 2, 3] // a is an array of ints\nb = [1.0, 2.0, 3.0] // b is an array of floats\nc = [\"a\", \"b\", \"c\"] // c is an array of strings\n\n// Arrays can be nested\nd = [[1, 2], [3, 4]] // d is an array of arrays of ints\n\n// Arrays can be empty\ne = [] // e is an empty array of unknown type\n
"},{"location":"data-types.html#hashmaps","title":"Hashmaps","text":"Hashmaps (or objects) are declared using the {}
syntax. The type of the object is the type of the fields it contains.
objects.rn// a is an object with fields x and y of type int\na = { x: 1, y: 2 };\n// b is an object with fields x and y of type float\nb = { x: 1.0, y: 2.0 };\n// c is an object with fields x and y of type string\nc = { x: \"a\", y: \"b\" };\n\n// Objects can be nested\n// d is an object with fields x and w of type object\nd = { x: { y: 1, z: 2 }, w: { y: 3, z: 4 } };\n\n// Objects can be empty\n// e is an empty object of unknown type\ne = {};\n
"},{"location":"error-handling.html","title":"Error Handling","text":"Error handling is an important part of writing maintainable code. Radon has a powerful exception handler. It can handle exceptions that may occur during the execution of a block of code.
"},{"location":"error-handling.html#handling-exceptions","title":"Handling exceptions","text":"In Radon, try-catch
blocks are used for error handling. The try
block contains the code that may throw an exception. The catch
block contains the code that handles the exception.
exceptions.rntry {\n // code that may throw an exception (in this case, zero division)\n a = 1 / 0\n} catch as err {\n // code that handles the exception\n print(\"Exception caught: \" + err)\n}\n
Output:
Exception caught: Division by zero\n
Don't forget to use the as
keyword to assign the exception to a variable. The variable can be used to get the exception message. If you don't want to use the exception message, you can omit the variable.
exceptions.rntry {\n // code that may throw an exception\n a = 1 / 0\n} catch as _ {\n // code that handles the exception\n print(\"Exception caught\")\n}\n
Output:
Exception caught\n
"},{"location":"error-handling.html#raise-exceptions","title":"Raise exceptions","text":"In Radon, errors can be raised explicitly using the raise
keyword. This is useful for enforcing certain conditions or for creating custom error messages.
Radon has a standard radiation
module for Error Types (you can type radiation.errors
in the shell to view a list of available error types)
exceptions.rnimport radiation\n\nif 2 != 4 {\n raise radiation.ValueError(\"2 != 4\")\n}\n
Output:
Radiation (most recent call last):\n File <stdin>, line 2\nValueError: 2 + 2 != 4\n\n raise radiation.ValueError(\"2 + 2 != 4\")\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
"},{"location":"error-handling.html#defining-custom-error-types","title":"Defining custom error types","text":"To define custom errors, you need to define a function that returns a string as the error message.
"},{"location":"error-handling.html#example","title":"Example","text":"custom-error.rnfun CustomError(file) {\n return \"Something went wrong in \" + file\n}\n\nraise CustomError(\"custom-error.rn\")\n
Output:
Radiation (most recent call last):\n File <stdin>, line 5\nFunctionError: Something went wrong in custom-error.rn\n\nraise CustomError(\"custom-error.rn\")\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
When the exception is raised, the program stops executing and the exception is propagated up the call stack. The exception can be caught by a try
block. If the exception is not caught, the program stops executing and the exception is printed to the console.
"},{"location":"file-handling.html","title":"File handling","text":"File handling is an essential part of any programming language. Radon provides a simple way to read and write files. In this section, we will learn how to read and write files in Radon.
"},{"location":"file-handling.html#file-modes","title":"File modes","text":"When opening a file, we can specify the mode in which we want to open the file.
The modes are:
r
: Read mode. Opens the file for reading. The file must exist. w
: Write mode. Opens the file for writing. If the file does not exist, it creates a new file. If the file exists, it truncates the file. a
: Append mode. Opens the file for writing. If the file does not exist, it creates a new file. If the file exists, it appends the content to the file. r+
: Read and write mode. Opens the file for reading and writing. The file must exist. w+
: Write and read mode. Opens the file for reading and writing. If the file does not exist, it creates a new file. If the file exists, it truncates the file. a+
: Append and read mode. Opens the file for reading and writing. If the file does not exist, it creates a new file. If the file exists, it appends the content to the file.
By default, the file is opened in read mode.
"},{"location":"file-handling.html#reading-from-a-file","title":"Reading from a file","text":"To manipulate files in Radon, we use built-in File
class. We can create a new instance of File
class by passing the file path to the constructor. We can then use the read
method to read the contents of the file.
file-handling.rnfile = File(\"file.txt\")\ncontent = file.read()\nprint(content)\n
You can also read the file line by line using the readline
method.
file-handling.rnfile = File(\"file.txt\")\nline = file.readline()\nprint(line)\n
You can also read all the lines of the file using the readlines
method.
file-handling.rnfile = File(\"file.txt\")\nlines = file.readlines()\nprint(lines)\n
"},{"location":"file-handling.html#writing-to-a-file","title":"Writing to a file","text":"To write to a file, we use the write
method. We can pass the content to the write
method to write to the file.
file-handling.rnfile = File(\"file.txt\")\nfile.write(\"Hello, World!\")\n
"},{"location":"file-handling.html#closing-a-file","title":"Closing a file","text":"After reading or writing to a file, it is important to close the file. We can use the close
method to close the file.
file-handling.rnfile = File(\"file.txt\")\n# code that reads or writes to the file\nfile.close()\n
Check the file is closed or not using the is_closed
method.
file-handling.rnfile.is_closed()\n
That's it! You now know how to read and write files in Radon.
"},{"location":"functions.html","title":"Functions","text":""},{"location":"functions.html#types-of-functions","title":"Types of functions","text":"Functions are the building blocks of a task. They are used to define the behavior of the program. In Radon, we declare functions using the fun
keyword. It is followed by the name of the function, the parameters, and the return type. The body of the function is enclosed in curly braces.
In Radon, there are three types of functions:
- Named functions
- Anonymous functions
- One-liner functions
"},{"location":"functions.html#named-functions","title":"Named functions","text":"named_functions.rnfun add(a, b) {\n return a + b\n}\n
"},{"location":"functions.html#anonymous-functions","title":"Anonymous functions","text":"anonymous_functions.rnadd = fun (a, b) {\n return a + b\n}\n
"},{"location":"functions.html#one-liner-functions","title":"One-liner functions","text":"one_liner_functions.rnfun add(a, b) -> a + b\n
"},{"location":"functions.html#calling-functions","title":"Calling functions","text":"Calling a function is done by using the function name followed by the arguments in parentheses.
calling_functions.rnadd(1, 2) # Output: 3\n
That's it! You now know how to call functions in Radon.
"},{"location":"functions.html#function-parameters","title":"Function parameters","text":"Function parameters are the names listed in the function definition. They are used to pass values into the function. The parameters are separated by commas. The parameters are optional.
We can also leave out the parentheses if there are no parameters.
function_parameters.rnfun say_hello(name) {\n print(\"Hello, \" + name + \"!\")\n}\n\nsay_hello(\"World\") # Output: Hello, World!\n
"},{"location":"functions.html#default-parameters","title":"Default parameters","text":"Default parameters are used to assign a default value to a parameter. If the parameter is not passed, the default value is used.
default_parameters.rnfun new_user(name=\"Guest\") {\n print(\"Hello, \" + name + \"!\")\n}\n\nnew_user() # Output: Hello, Guest!\nnew_user(\"World\") # Output: Hello, World!\n
"},{"location":"input-output.html","title":"Input Output","text":""},{"location":"input-output.html#printing-to-the-console","title":"Printing to the console","text":"In Radon, we can print to the console using the print
function. It is followed by the argument in parentheses. The argument are mandatory. It takes only one argument. We can concatenate data types using the +
operator.
print.rnprint(\"Hello\" + \", \" + \"World!\") # Output: Hello, World!\n
"},{"location":"input-output.html#input-from-the-console","title":"Input from the console","text":"In Radon, we can take input from the console using the input
function. It is followed by the argument in parentheses. The argument are mandatory. It takes only one argument. We can concatenate data types using the +
operator.
input.rnname = input(\"Enter your name: \")\nprint(\"Hello, \" + name + \"!\") # Output: Hello, World!\n
"},{"location":"installation.html","title":"Installation","text":"It's easy to install Radon on your computer. Just go to the downloads page and download the latest version for your operating system. Then, follow the instructions below for your operating system. If you have any problems, please contact us and we'll help you out.
"},{"location":"installation.html#windows","title":"Windows","text":"To install Radon on Windows, just download the installer from the downloads page and run it. Then, follow the instructions on the screen to install Radon on your computer.
After setup you need to manually configure the PATH environment variable. To do this, open the Control Panel and go to System and Security > System > Advanced system settings > Environment Variables. Then, select the PATH variable and click Edit. Add the path to the Radon bin directory to the end of the variable value. For example, if you installed Radon in C:\\Program Files (x86)\\Radon, you would add C:\\Program Files (x86)\\Radon to the end of the variable value. Then, click OK to save the changes.
Quick tip: You can also set the PATH variable from the command line. Just open a command prompt and type the following command:
Command prompt (Windows)setx PATH \"%PATH%;C:\\Program Files (x86)\\Radon\"\n
Now, you can open a command prompt and type radon to run Radon. If you get an error message, try restarting your computer and trying again.
"},{"location":"installation.html#macos","title":"macOS","text":"Mac installer is not available yet. You can download the source code and build it yourself.
"},{"location":"installation.html#linux","title":"Linux","text":"Linux installer is not available yet. You can download the source code and build it yourself.
Linux users don't need any instructions!!
"},{"location":"language-reference.html","title":"Language Reference","text":""},{"location":"language-reference.html#under-maintenance","title":"Under Maintenance","text":"The language reference is currently under maintenance. Please check back later.
Thank you for your patience.
"},{"location":"loops.html","title":"Loops","text":"Loops are used to execute a block of code multiple times. The block of code will be executed until the condition is true. This help us to reduce the code and execute the same block of code multiple times.
In Radon we have 2 types of loops.
for
loop. while
loop.
"},{"location":"loops.html#for-loop","title":"For loop","text":"In for loop we have 2 varients.
for
loop with range. for
loop with sequence of elements.
"},{"location":"loops.html#for-loop-with-range","title":"For loop with range","text":"With range we can specify the start, end and step value. If step value is not provided then it will be 1.
for i=0 to 10 {\n print(i)\n}\n
Output:
0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
With step value. Here we are printing the even numbers.
for i=0 to 10 step 2 {\n print(i)\n}\n
Output:
0\n2\n4\n6\n8\n
"},{"location":"loops.html#for-loop-with-sequence-of-elements","title":"For loop with sequence of elements","text":"With sequence of elements we can specify the elements in the loop. The loop will run for each element.
Here we are using Array
of elements. The loop will run for each element in the Array
.
for i in [1, 2, 3, 4, 5] {\n print(i)\n}\n
Output
1\n2\n3\n4\n5\n
Here we are using String
. The loop will run for each character in the String
.
for i in \"Hello\" {\n print(i)\n}\n
Output:
H\ne\nl\nl\no\n
Here we are using HashMap
. The loop will run for each key in the HashMap
.
hash = {\"name\": \"John\", \"age\": 30}\nfor i in hash {\n print(\"Key: \" + i)\n print(\"Value: \" + hash[i])\n}\n
Output:
Key: name\nValue: John\nKey: age\nValue: 30\n
"},{"location":"loops.html#while-loop","title":"While loop","text":"With while loop we can specify the condition. The loop will run until the condition is true.
i = 0\nwhile i < 5 {\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n3\n4\n
We have used nonlocal
keyword to update the value of i
in the loop. If we don't use nonlocal
then it will run into infinite loop.
"},{"location":"loops.html#loop-control-statements","title":"Loop control statements","text":"In Radon we have 2 loop control statements.
break
continue
"},{"location":"loops.html#break","title":"Break","text":"With break
we can exit the loop.
For loop example:
for i=0 to 10 {\n if i == 5 {\n break\n }\n print(i)\n}\n
Output:
0\n1\n2\n3\n4\n
While loop example:
i = 0\nwhile i < 10 {\n if i == 5 {\n break\n }\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n3\n4\n
"},{"location":"loops.html#continue","title":"Continue","text":"With continue
we can skip the current iteration and move to the next iteration.
For loop example:
for i=0 to 5 {\n if i == 3 {\n continue\n }\n print(i)\n}\n
Output:
0\n1\n2\n4\n
While loop example:
i = 0\nwhile i < 5 {\n if i == 3 {\n nonlocal i += 1\n continue\n }\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n4\n
That's all about loops in Radon.
"},{"location":"modules.html","title":"Modules","text":""},{"location":"modules.html#introduction-to-modules","title":"Introduction to Modules","text":"Modules are a way to organize code in a way that is easy to reuse, test, and debug. Modules are also called packages, libraries, or frameworks. Modules are used to group related code together. For example, a module can be used to group code that is related to a specific task, such as sending an email. Modules are also used to group code that is related to a specific feature, such as a user interface.
"},{"location":"modules.html#creating-a-module","title":"Creating a Module","text":"A module is created by creating a file with the .rn
extension. The file name is the name of the module. The name should have to be in Pascal Case PascalCase
. The module have to implement the same name class as the file name. The class name should have to be in Pascal Case PascalCase
.
Hello.rnclass Hello {\n fun __constructor__() {\n print(\"Hello, World!\")\n }\n}\n
"},{"location":"modules.html#importing-a-module","title":"Importing a Module","text":"A module is imported by using the include
keyword. It is followed by the name of the module. The name of the module should have to be in Pascal Case PascalCase
.
importing.rnimport Hello\n
"},{"location":"quick-start.html","title":"Quick start","text":"To get started with Radon language you can use the built-in REPL or just run the Radon file. Run a Radon file by typing radon -s <filename>.rn
in the command line. For example, if you have a file named hello.rn
you can run it by typing radon -s hello.rn
in the command line.
"},{"location":"quick-start.html#repl","title":"REPL","text":"The REPL is a command line interface that allows you to run Radon code interactively. To start the REPL, just type radon
in the command line. You can then type Radon code and it will be executed immediately. To exit the REPL, just type exit()
or press Ctrl + Z
.
"},{"location":"quick-start.html#hello-world","title":"Hello World","text":"The first program that most people write in a new language is the \"Hello World\" program. This program simply prints the words \"Hello World\" to the screen. Here is the \"Hello World\" program in Radon:
HelloWorld.rnprint(\"Hello World\")\n
"},{"location":"standard-library.html","title":"Standard Library","text":""},{"location":"standard-library.html#list-of-standard-libraries","title":"List of Standard Libraries","text":"*\n\u251c\u2500\u2500 stdlib\n\u2502 \u251c\u2500\u2500 argparser.rn\n\u2502 \u251c\u2500\u2500 array.rn\n\u2502 \u251c\u2500\u2500 colorlib.rn\n\u2502 \u251c\u2500\u2500 math.rn\n\u2502 \u251c\u2500\u2500 radiation.rn\n\u2502 \u251c\u2500\u2500 string.rn\n\u2502 \u251c\u2500\u2500 system.rn\n\u2502 \u2514\u2500\u2500 winlib.rn\n
... and more to come! Under development.
"},{"location":"strings.html","title":"Strings","text":""},{"location":"strings.html#string-methods","title":"String methods","text":" str_len()
- returns the length of the string. str_find(string, index)
- returns the character at the specified index. str_slice(string, start, end)
- returns the substring from the specified start index to the specified end index
methods.rnstr = \"Hello, World!\"\n\nprint(str_len(str)) # 13\nprint(str_find(str, 0)) # H\nprint(str_find(str, 1)) # e\n\nprint(str_slice(str, 0, 5)) # Hello\n
"},{"location":"strings.html#string-operators","title":"String operators","text":" +
(concatenation) *
(repetition)
operators.rnstr = \"Hello, World!\"\n\nprint(str + \" \" + \"Hello, World!\") # Hello, World! Hello, World!\nprint(str * 2) # Hello, World!Hello, World!\n
"},{"location":"strings.html#string-type-casting","title":"String type casting","text":" str()
- converts any value to a string
casting.rnprint(str(123)) # 123\nprint(str(123.456)) # 123.456\nprint(str(true)) # true\nprint(str(false)) # false\n
"},{"location":"strings.html#string-type-checking","title":"String type checking","text":" is_str()
- returns true
if the value is a string, otherwise false
type-checking.rnprint(is_str(\"Hello, World!\")) # true\nprint(is_str(123)) # false\nprint(is_str(123.456)) # false\nprint(is_str(true)) # false\nprint(is_str(false)) # false\n
"},{"location":"tools.html","title":"Tools","text":""},{"location":"blog/hello-world.html","title":"Hello World","text":""},{"location":"blog/hello-world.html#introduction","title":"Introduction","text":"We are excited to announce the launch Radon - a new open source programming language for the modern world. The language is designed to be simple, fast, and safe while incorporating modern language features such as type inference, pattern matching, and more. A key goal of the language is to be easy to learn and use, while still being powerful enough to build complex applications. It is also designed to be easy to embed in other applications, and to be used as a scripting language. The language is currently in the early stages of development, and we are looking for contributors to help us build the language.
"},{"location":"blog/hello-world.html#about-the-author","title":"About the author","text":"Md. Almas Ali is a software engineer and a programming language enthusiast. He is the creator of the Radon programming language. He has a lot of projects in his GitHub profile. Checkout his GitHub profile for more information.
Created on: 12 Sep 2023 - 2:39 AM (GMT+6)
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"index.html","title":"The Radon Programming Language","text":"Radon is a programming language that is designed to be easy to learn and use. Maintained by Md. Almas Ali
Website: https://radon-project.github.io
Documentation: https://radon-project.github.io/docs
Github: https://github.com/radon-project/radon
"},{"location":"index.html#introduction","title":"Introduction","text":"Radon is a programming language that is designed to be easy to learn and use. It is a high-level language intended to be used for general purpose programming. It is designed to be easy to learn and use, while still being powerful enough to be used for most tasks.
Some of the features of Radon include:
- A simple syntax that is easy to learn and use
- Dynamic typing so that you don't have to worry about types
- Powerful standard library that makes it easy to do common tasks (Development)
- Easy to use package manager that makes it easy to install packages (Future feature)
- Functional programming support
- Object-oriented programming support (Development)
- Easy to use concurrency support (Future feature)
- Easy to use GUI library (Future feature)
- Easy to use web development library (Future feature)
- Advanced command line interface (Development)
- Easy to use networking library (Future feature)
- Easy to use database library (Future feature)
- Easy to use graphics library (Future feature)
"},{"location":"index.html#login-logic","title":"Login Logic","text":"Login.rn# This is a Radon test file for the Radon Programming Language.\n\nclass Network {\n fun __constructor__(username, password) {\n this.username = username\n this.password = password\n }\n\n fun login() {\n if this.username == \"radon\" {\n if this.password == \"password\" {\n print(\"Log in successful\")\n }\n } else {\n print(\"Invalid credentials\")\n }\n }\n}\n\nusername = input(\"Enter you username: \")\npassword = input(\"Enter your password: \")\n\nnetwork = Network(username, password)\nnetwork.login()\n
"},{"location":"index.html#sponsors","title":"Sponsors","text":"No sponsors yet. Be the first one to sponsor this project. Become a sponsor
"},{"location":"arrays.html","title":"Arrays","text":""},{"location":"arrays.html#built-in-array-methods","title":"Built-in Array methods","text":" arr_len()
or len(arr)
- returns the length of the array arr_push(array, item)
- adds an item to the end of the array arr_pop(array, index)
- removes an item from the end of the array arr_append(array, item)
- adds an item to the end of the array arr_extend(array1, array2)
- adds all the items of an array to the end of the array arr_find(array, index)
- returns the item at the specified index arr_slice(array, start, end)
- returns the items from the specified start index to the specified end index
methods.rnarr = [1, 2, 3, 4, 5]\nprint(arr_len(arr)) # 5\n\narr_push(arr, 6)\nprint(arr) # [1, 2, 3, 4, 5, 6]\n\narr_pop(arr)\nprint(arr) # [1, 2, 3, 4, 5]\n\narr_append(arr, 6)\nprint(arr) # [1, 2, 3, 4, 5, 6]\n\narr_extend(arr, [7, 8, 9])\nprint(arr) # [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\nprint(arr_find(arr, 0)) # 1\nprint(arr_find(arr, 1)) # 2\n\nprint(arr_slice(arr, 0, 5)) # [1, 2, 3, 4, 5]\n
"},{"location":"arrays.html#array-operators","title":"Array operators","text":" +
(concatenation) *
(repetition)
operators.rnarr1 = [1, 2, 3]\narr2 = [4, 5, 6]\n\nprint(arr1 + arr2) # [1, 2, 3, 4, 5, 6]\nprint(arr1 * 2) # [1, 2, 3, 1, 2, 3]\n
"},{"location":"arrays.html#array-standard-library","title":"Array standard library","text":" map(func)
- returns a new array with the result of calling the specified function on each item of the array append(item)
- adds an item to the end of the array pop(index)
- removes an item from the end of the array extend(list)
- adds all the items of an array to the end of the array find(index)
- returns the item at the specified index slice(start, end)
- returns the items from the specified start index to the specified end index len()
- returns the length of the array is_empty()
- returns true
if the array is empty, otherwise false
to_string()
- returns the string representation of the array is_array()
- returns true
if the value is an array, otherwise false
array-standard-library.rnimport Array # Include the Array standard library\n\n# Create an array instance using the Array class\narr = Array([1, 2, 3, 4, 5])\n\nprint(len(arr)) # 5\nprint(arr.is_empty()) # false\nprint(arr.to_string()) # \"[1, 2, 3, 4, 5]\"\nprint(arr.is_array()) # true\n\nprint(arr.map(fun (item) -> str(item))) # [\"1\", \"2\", \"3\", \"4\", \"5\"]\n\nprint(arr.append(6)) # [1, 2, 3, 4, 5, 6]\nprint(arr.pop(5)) # [1, 2, 3, 4, 5]\n\nprint(arr.extend([6, 7, 8])) # [1, 2, 3, 4, 5, 6, 7, 8]\nprint(arr.find(0)) # 1\nprint(arr.find(1)) # 2\n\nprint(arr.slice(0, 5)) # [1, 2, 3, 4, 5]\n
"},{"location":"built-in-functions.html","title":"Built-in Functions","text":""},{"location":"built-in-functions.html#types-of-built-in-functions","title":"Types of built-in functions","text":"Built-in functions are the functions that are built into the language. They are used to perform common tasks. In Radon, there are a list of built-in functions that are available to use.
They are:
"},{"location":"built-in-functions.html#utility-methods","title":"Utility methods","text":" cls()
- clears the screen. clear()
- clears the screen. exit()
- exits the program.
"},{"location":"built-in-functions.html#shell-commands","title":"Shell commands","text":" help(obj)
- get help about any object license()
- show project license credits()
- show project credits
"},{"location":"built-in-functions.html#same-as-import-statement","title":"Same as import
statement","text":" require()
- same as include statement to include a file or library in the current program.
"},{"location":"built-in-functions.html#command-line-arguments","title":"Command line arguments","text":" sys_args()
- returns the command line arguments.
"},{"location":"built-in-functions.html#api-methods","title":"API methods","text":" pyapi(string,ns)
- A high-level Python API for Radon. It is used to call Python functions from Radon.
"},{"location":"built-in-functions.html#typecase-methods","title":"Typecase methods","text":" int()
- converts any value to an integer. float()
- converts any value to a float. str()
- converts any value to a string. bool()
- converts any value to a boolean. type()
- returns the type of the value.
"},{"location":"built-in-functions.html#type-checker-methods","title":"Type checker methods","text":" is_num()
- returns true
if the value is a number, otherwise false
. is_int()
- returns true
if the value is an integer, otherwise false
. is_float()
- returns true
if the value is a float, otherwise false
. is_str()
- returns true
if the value is a string, otherwise false
. is_bool()
- returns true
if the value is a boolean, otherwise false
. is_array()
- returns true
if the value is an array, otherwise false
. is_fun()
- returns true
if the value is a function, otherwise false
.
"},{"location":"built-in-functions.html#string-methods","title":"String methods","text":" str_len()
- returns the length of the string. str_find(string, index)
- returns the character at the specified index. str_slice(string, start, end)
- returns the substring from the specified start index to the specified end index.
"},{"location":"built-in-functions.html#io-methods","title":"I/O methods","text":" print()
- prints the specified value to the console. print_ret()
- prints the specified value to the console and returns the value. input()
- reads a line from the console. input_int()
- reads an integer from the console.
"},{"location":"built-in-functions.html#array-methods","title":"Array methods","text":" arr_len()
- returns the length of the array. arr_push(array, item)
- adds an item to the end of the array. arr_pop(array, index)
- removes an item from the end of the array. arr_append(array, item)
- adds an item to the end of the array. arr_extend(array1, array2)
- adds all the items of an array to the end of the array. arr_find(array, index)
- returns the item at the specified index. arr_slice(array, start, end)
- returns the items from the specified start index to the specified end index.
"},{"location":"classes.html","title":"Classes and Objects","text":""},{"location":"classes.html#object-oriented-programming","title":"Object Oriented Programming","text":"Object Oriented Programming (OOP) is a programming paradigm that uses objects and their interactions to design and program applications. It is based on the concept of objects rather than just functions and procedures. These objects are organized into classes, which allow individual objects to be grouped together. Most modern programming languages including Java, C/C++, and Python are object-oriented languages, and many older programming languages now have object-oriented versions.
In Radon, we also have support for OOP. We can create classes and objects. We can also create methods and fields.
"},{"location":"classes.html#classes","title":"Classes","text":"Let's start by creating a class. We can create a class using the class
keyword. It is followed by the name of the class and the body of the class. The body of the class is enclosed in curly braces.
classes.rnclass Person {\n # Class body\n}\n
"},{"location":"classes.html#objects","title":"Objects","text":"Now that we have created a class, we can create an object. We can create an object by simply calling the class like as a function. It is followed by the name of the class and the arguments in parentheses. The arguments are optional.
objects.rnperson = Person()\n
"},{"location":"classes.html#fields","title":"Fields","text":"Fields are the variables that are declared inside a class. They are used to store data. They are also called instance variables because they are unique to each instance of the class. They are declared using the var
keyword. It is followed by the name of the field and the type of the field. The type of the field is optional.
fields.rnclass Person {\n name = \"John\"\n age = 20\n}\n
"},{"location":"classes.html#constructors","title":"Constructors","text":"Constructors are special methods that are used to initialize the fields of a class. They are called when an object is created. They are declared using the fun
keyword. It is followed by the name (class name) of the constructor and the parameters in parentheses. The parameters are optional.
constructors.rnclass Person {\n fun Person(name, age) {\n this.name = name\n this.age = age\n }\n}\n\nperson = Person(\"John\", 20)\n
"},{"location":"classes.html#methods","title":"Methods","text":"Methods are the functions that are declared inside a class. They are used to define the behavior of the class. They are declared using the fun
keyword. It is followed by the name of the method, the parameters in parentheses, and the return type. The parameters and the return type are optional.
methods.rnclass Person {\n fun __constructor__(name, age) {\n this.name = name\n this.age = age\n }\n\n fun say_hello() {\n print(\"Hello, \" + this.name + \"!\")\n }\n}\n\nperson = Person(\"John\", 20)\nperson.say_hello() # Output: Hello, John!\n
"},{"location":"contribution.html","title":"Contribution","text":""},{"location":"contribution.html#how-to-contribute","title":"How to contribute","text":"We need contributors to help us build the language. If you are interested, please make contributions to the radon-project/radon
repository.
Steps to contribute:
- Fork the repository.
- Clone the repository.
- Create a new branch.
- Make changes.
- Commit changes.
- Push to the branch.
- Create a pull request.
Before making a pull request create an issue and discuss the changes you want to make. If you have any questions, feel free to ask in the issues section.
"},{"location":"control-flow.html","title":"Control flow","text":""},{"location":"control-flow.html#conditional-statements","title":"Conditional statements","text":"Conditional statements are used to execute code based on a condition. In Rain, the if
statement is used to execute code if a condition is true. The else
statement is used to execute code if the condition is false. The elif
statement is used to execute code if the condition is false and another condition is true. The else
statement is optional.
conditional-statements.rnif true {\n print(\"true\")\n\n} else {\n print(\"false\")\n}\n
conditional-statements.rnif true {\n print(\"true\")\n\n} elif false {\n print(\"false\")\n\n} else {\n print(\"neither\")\n}\n
"},{"location":"data-types.html","title":"Data types","text":""},{"location":"data-types.html#basic-types","title":"Basic types","text":"The basic types are:
int
- integer number. float
- floating point number. bool
- boolean value. string
- string of characters.
"},{"location":"data-types.html#arrays","title":"Arrays","text":"Arrays are declared using the []
syntax. The type of the array is the type of the elements it contains.
arrays.rna = [1, 2, 3] // a is an array of ints\nb = [1.0, 2.0, 3.0] // b is an array of floats\nc = [\"a\", \"b\", \"c\"] // c is an array of strings\n\n// Arrays can be nested\nd = [[1, 2], [3, 4]] // d is an array of arrays of ints\n\n// Arrays can be empty\ne = [] // e is an empty array of unknown type\n
"},{"location":"data-types.html#hashmaps","title":"Hashmaps","text":"Hashmaps (or objects) are declared using the {}
syntax. The type of the object is the type of the fields it contains.
objects.rn// a is an object with fields x and y of type int\na = { x: 1, y: 2 };\n// b is an object with fields x and y of type float\nb = { x: 1.0, y: 2.0 };\n// c is an object with fields x and y of type string\nc = { x: \"a\", y: \"b\" };\n\n// Objects can be nested\n// d is an object with fields x and w of type object\nd = { x: { y: 1, z: 2 }, w: { y: 3, z: 4 } };\n\n// Objects can be empty\n// e is an empty object of unknown type\ne = {};\n
"},{"location":"error-handling.html","title":"Error Handling","text":"Error handling is an important part of writing maintainable code. Radon has a powerful exception handler. It can handle exceptions that may occur during the execution of a block of code.
"},{"location":"error-handling.html#handling-exceptions","title":"Handling exceptions","text":"In Radon, try-catch
blocks are used for error handling. The try
block contains the code that may throw an exception. The catch
block contains the code that handles the exception.
exceptions.rntry {\n // code that may throw an exception (in this case, zero division)\n a = 1 / 0\n} catch as err {\n // code that handles the exception\n print(\"Exception caught: \" + err)\n}\n
Output:
Exception caught: Division by zero\n
Don't forget to use the as
keyword to assign the exception to a variable. The variable can be used to get the exception message. If you don't want to use the exception message, you can omit the variable.
exceptions.rntry {\n // code that may throw an exception\n a = 1 / 0\n} catch as _ {\n // code that handles the exception\n print(\"Exception caught\")\n}\n
Output:
Exception caught\n
"},{"location":"error-handling.html#raise-exceptions","title":"Raise exceptions","text":"In Radon, errors can be raised explicitly using the raise
keyword. This is useful for enforcing certain conditions or for creating custom error messages.
Radon has a standard radiation
module for Error Types (you can type radiation.errors
in the shell to view a list of available error types)
exceptions.rnimport radiation\n\nif 2 != 4 {\n raise radiation.ValueError(\"2 != 4\")\n}\n
Output:
Radiation (most recent call last):\n File <stdin>, line 2\nValueError: 2 + 2 != 4\n\n raise radiation.ValueError(\"2 + 2 != 4\")\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
"},{"location":"error-handling.html#defining-custom-error-types","title":"Defining custom error types","text":"To define custom errors, you need to define a function that returns a string as the error message.
"},{"location":"error-handling.html#example","title":"Example","text":"custom-error.rnfun CustomError(file) {\n return \"Something went wrong in \" + file\n}\n\nraise CustomError(\"custom-error.rn\")\n
Output:
Radiation (most recent call last):\n File <stdin>, line 5\nFunctionError: Something went wrong in custom-error.rn\n\nraise CustomError(\"custom-error.rn\")\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
When the exception is raised, the program stops executing and the exception is propagated up the call stack. The exception can be caught by a try
block. If the exception is not caught, the program stops executing and the exception is printed to the console.
"},{"location":"file-handling.html","title":"File handling","text":"File handling is an essential part of any programming language. Radon provides a simple way to read and write files. In this section, we will learn how to read and write files in Radon.
"},{"location":"file-handling.html#security-notice-executing-any-file-operations-will-prompt-the-user-for-confirmation-before-proceeding-for-example","title":"SECURITY NOTICE: Executing any file operations will prompt the user for confirmation before proceeding, for example:","text":"[DISK_ACCESS] This program is attempting to access the disk. Continue execution?\n[Y/n] -> _\n
"},{"location":"file-handling.html#file-modes","title":"File modes","text":"When opening a file, we can specify the mode in which we want to open the file.
The modes are:
r
: Read mode. Opens the file for reading. The file must exist. w
: Write mode. Opens the file for writing. If the file does not exist, it creates a new file. If the file exists, it truncates the file. a
: Append mode. Opens the file for writing. If the file does not exist, it creates a new file. If the file exists, it appends the content to the file. r+
: Read and write mode. Opens the file for reading and writing. The file must exist. w+
: Write and read mode. Opens the file for reading and writing. If the file does not exist, it creates a new file. If the file exists, it truncates the file. a+
: Append and read mode. Opens the file for reading and writing. If the file does not exist, it creates a new file. If the file exists, it appends the content to the file.
By default, the file is opened in read mode.
"},{"location":"file-handling.html#reading-from-a-file","title":"Reading from a file","text":"To manipulate files in Radon, we use built-in File
class. We can create a new instance of File
class by passing the file path to the constructor. We can then use the read
method to read the contents of the file.
file-handling.rnfile = File(\"file.txt\")\ncontent = file.read()\nprint(content)\n
You can also read the file line by line using the readline
method.
file-handling.rnfile = File(\"file.txt\")\nline = file.readline()\nprint(line)\n
You can also read all the lines of the file using the readlines
method.
file-handling.rnfile = File(\"file.txt\")\nlines = file.readlines()\nprint(lines)\n
"},{"location":"file-handling.html#writing-to-a-file","title":"Writing to a file","text":"To write to a file, we use the write
method. We can pass the content to the write
method to write to the file.
file-handling.rnfile = File(\"file.txt\")\nfile.write(\"Hello, World!\")\n
"},{"location":"file-handling.html#closing-a-file","title":"Closing a file","text":"After reading or writing to a file, it is important to close the file. We can use the close
method to close the file.
file-handling.rnfile = File(\"file.txt\")\n# code that reads or writes to the file\nfile.close()\n
Check the file is closed or not using the is_closed
method.
file-handling.rnfile.is_closed()\n
That's it! You now know how to read and write files in Radon.
"},{"location":"functions.html","title":"Functions","text":""},{"location":"functions.html#types-of-functions","title":"Types of functions","text":"Functions are the building blocks of a task. They are used to define the behavior of the program. In Radon, we declare functions using the fun
keyword. It is followed by the name of the function, the parameters, and the return type. The body of the function is enclosed in curly braces.
In Radon, there are three types of functions:
- Named functions
- Anonymous functions
- One-liner functions
"},{"location":"functions.html#named-functions","title":"Named functions","text":"named_functions.rnfun add(a, b) {\n return a + b\n}\n
"},{"location":"functions.html#anonymous-functions","title":"Anonymous functions","text":"anonymous_functions.rnadd = fun (a, b) {\n return a + b\n}\n
"},{"location":"functions.html#one-liner-functions","title":"One-liner functions","text":"one_liner_functions.rnfun add(a, b) -> a + b\n
"},{"location":"functions.html#calling-functions","title":"Calling functions","text":"Calling a function is done by using the function name followed by the arguments in parentheses.
calling_functions.rnadd(1, 2) # Output: 3\n
That's it! You now know how to call functions in Radon.
"},{"location":"functions.html#function-parameters","title":"Function parameters","text":"Function parameters are the names listed in the function definition. They are used to pass values into the function. The parameters are separated by commas. The parameters are optional.
We can also leave out the parentheses if there are no parameters.
function_parameters.rnfun say_hello(name) {\n print(\"Hello, \" + name + \"!\")\n}\n\nsay_hello(\"World\") # Output: Hello, World!\n
"},{"location":"functions.html#default-parameters","title":"Default parameters","text":"Default parameters are used to assign a default value to a parameter. If the parameter is not passed, the default value is used.
default_parameters.rnfun new_user(name=\"Guest\") {\n print(\"Hello, \" + name + \"!\")\n}\n\nnew_user() # Output: Hello, Guest!\nnew_user(\"World\") # Output: Hello, World!\n
"},{"location":"input-output.html","title":"Input Output","text":""},{"location":"input-output.html#printing-to-the-console","title":"Printing to the console","text":"In Radon, we can print to the console using the print
function. It is followed by the argument in parentheses. The argument are mandatory. It takes only one argument. We can concatenate data types using the +
operator.
print.rnprint(\"Hello\" + \", \" + \"World!\") # Output: Hello, World!\n
"},{"location":"input-output.html#input-from-the-console","title":"Input from the console","text":"In Radon, we can take input from the console using the input
function. It is followed by the argument in parentheses. The argument are mandatory. It takes only one argument. We can concatenate data types using the +
operator.
input.rnname = input(\"Enter your name: \")\nprint(\"Hello, \" + name + \"!\") # Output: Hello, World!\n
"},{"location":"installation.html","title":"Installation","text":"It's easy to install Radon on your computer. Just go to the downloads page and download the latest version for your operating system. Then, follow the instructions below for your operating system. If you have any problems, please contact us and we'll help you out.
"},{"location":"installation.html#windows","title":"Windows","text":"To install Radon on Windows, just download the installer from the downloads page and run it. Then, follow the instructions on the screen to install Radon on your computer.
After setup you need to manually configure the PATH environment variable. To do this, open the Control Panel and go to System and Security > System > Advanced system settings > Environment Variables. Then, select the PATH variable and click Edit. Add the path to the Radon bin directory to the end of the variable value. For example, if you installed Radon in C:\\Program Files (x86)\\Radon, you would add C:\\Program Files (x86)\\Radon to the end of the variable value. Then, click OK to save the changes.
Quick tip: You can also set the PATH variable from the command line. Just open a command prompt and type the following command:
Command prompt (Windows)setx PATH \"%PATH%;C:\\Program Files (x86)\\Radon\"\n
Now, you can open a command prompt and type radon to run Radon. If you get an error message, try restarting your computer and trying again.
"},{"location":"installation.html#macos","title":"macOS","text":"Mac installer is not available yet. You can download the source code and build it yourself.
"},{"location":"installation.html#linux","title":"Linux","text":"Linux installer is not available yet. You can download the source code and build it yourself.
Linux users don't need any instructions!!
"},{"location":"language-reference.html","title":"Language Reference","text":""},{"location":"language-reference.html#under-maintenance","title":"Under Maintenance","text":"The language reference is currently under maintenance. Please check back later.
Thank you for your patience.
"},{"location":"loops.html","title":"Loops","text":"Loops are used to execute a block of code multiple times. The block of code will be executed until the condition is true. This help us to reduce the code and execute the same block of code multiple times.
In Radon we have 2 types of loops.
for
loop. while
loop.
"},{"location":"loops.html#for-loop","title":"For loop","text":"In for loop we have 2 varients.
for
loop with range. for
loop with sequence of elements.
"},{"location":"loops.html#for-loop-with-range","title":"For loop with range","text":"With range we can specify the start, end and step value. If step value is not provided then it will be 1.
for i=0 to 10 {\n print(i)\n}\n
Output:
0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
With step value. Here we are printing the even numbers.
for i=0 to 10 step 2 {\n print(i)\n}\n
Output:
0\n2\n4\n6\n8\n
"},{"location":"loops.html#for-loop-with-sequence-of-elements","title":"For loop with sequence of elements","text":"With sequence of elements we can specify the elements in the loop. The loop will run for each element.
Here we are using Array
of elements. The loop will run for each element in the Array
.
for i in [1, 2, 3, 4, 5] {\n print(i)\n}\n
Output
1\n2\n3\n4\n5\n
Here we are using String
. The loop will run for each character in the String
.
for i in \"Hello\" {\n print(i)\n}\n
Output:
H\ne\nl\nl\no\n
Here we are using HashMap
. The loop will run for each key in the HashMap
.
hash = {\"name\": \"John\", \"age\": 30}\nfor i in hash {\n print(\"Key: \" + i)\n print(\"Value: \" + hash[i])\n}\n
Output:
Key: name\nValue: John\nKey: age\nValue: 30\n
"},{"location":"loops.html#while-loop","title":"While loop","text":"With while loop we can specify the condition. The loop will run until the condition is true.
i = 0\nwhile i < 5 {\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n3\n4\n
We have used nonlocal
keyword to update the value of i
in the loop. If we don't use nonlocal
then it will run into infinite loop.
"},{"location":"loops.html#loop-control-statements","title":"Loop control statements","text":"In Radon we have 2 loop control statements.
break
continue
"},{"location":"loops.html#break","title":"Break","text":"With break
we can exit the loop.
For loop example:
for i=0 to 10 {\n if i == 5 {\n break\n }\n print(i)\n}\n
Output:
0\n1\n2\n3\n4\n
While loop example:
i = 0\nwhile i < 10 {\n if i == 5 {\n break\n }\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n3\n4\n
"},{"location":"loops.html#continue","title":"Continue","text":"With continue
we can skip the current iteration and move to the next iteration.
For loop example:
for i=0 to 5 {\n if i == 3 {\n continue\n }\n print(i)\n}\n
Output:
0\n1\n2\n4\n
While loop example:
i = 0\nwhile i < 5 {\n if i == 3 {\n nonlocal i += 1\n continue\n }\n print(i)\n nonlocal i += 1\n}\n
Output:
0\n1\n2\n4\n
That's all about loops in Radon.
"},{"location":"modules.html","title":"Modules","text":""},{"location":"modules.html#introduction-to-modules","title":"Introduction to Modules","text":"Modules are a way to organize code in a way that is easy to reuse, test, and debug. Modules are also called packages, libraries, or frameworks. Modules are used to group related code together. For example, a module can be used to group code that is related to a specific task, such as sending an email. Modules are also used to group code that is related to a specific feature, such as a user interface.
"},{"location":"modules.html#creating-a-module","title":"Creating a Module","text":"A module is created by creating a file with the .rn
extension. The file name is the name of the module. The name should have to be in Pascal Case PascalCase
. The module have to implement the same name class as the file name. The class name should have to be in Pascal Case PascalCase
.
Hello.rnclass Hello {\n fun __constructor__() {\n print(\"Hello, World!\")\n }\n}\n
"},{"location":"modules.html#importing-a-module","title":"Importing a Module","text":"A module is imported by using the include
keyword. It is followed by the name of the module. The name of the module should have to be in Pascal Case PascalCase
.
importing.rnimport Hello\n
"},{"location":"quick-start.html","title":"Quick start","text":"To get started with Radon language you can use the built-in REPL or just run the Radon file. Run a Radon file by typing radon -s <filename>.rn
in the command line. For example, if you have a file named hello.rn
you can run it by typing radon -s hello.rn
in the command line.
"},{"location":"quick-start.html#repl","title":"REPL","text":"The REPL is a command line interface that allows you to run Radon code interactively. To start the REPL, just type radon
in the command line. You can then type Radon code and it will be executed immediately. To exit the REPL, just type exit()
or press Ctrl + Z
.
"},{"location":"quick-start.html#hello-world","title":"Hello World","text":"The first program that most people write in a new language is the \"Hello World\" program. This program simply prints the words \"Hello World\" to the screen. Here is the \"Hello World\" program in Radon:
HelloWorld.rnprint(\"Hello World\")\n
"},{"location":"standard-library.html","title":"Standard Library","text":""},{"location":"standard-library.html#list-of-standard-libraries","title":"List of Standard Libraries","text":"*\n\u251c\u2500\u2500 stdlib\n\u2502 \u251c\u2500\u2500 argparser.rn\n\u2502 \u251c\u2500\u2500 array.rn\n\u2502 \u251c\u2500\u2500 colorlib.rn\n\u2502 \u251c\u2500\u2500 math.rn\n\u2502 \u251c\u2500\u2500 radiation.rn\n\u2502 \u251c\u2500\u2500 string.rn\n\u2502 \u251c\u2500\u2500 system.rn\n\u2502 \u2514\u2500\u2500 winlib.rn\n
... and more to come! Under development.
"},{"location":"strings.html","title":"Strings","text":""},{"location":"strings.html#string-methods","title":"String methods","text":" str_len()
- returns the length of the string. str_find(string, index)
- returns the character at the specified index. str_slice(string, start, end)
- returns the substring from the specified start index to the specified end index
methods.rnstr = \"Hello, World!\"\n\nprint(str_len(str)) # 13\nprint(str_find(str, 0)) # H\nprint(str_find(str, 1)) # e\n\nprint(str_slice(str, 0, 5)) # Hello\n
"},{"location":"strings.html#string-operators","title":"String operators","text":" +
(concatenation) *
(repetition)
operators.rnstr = \"Hello, World!\"\n\nprint(str + \" \" + \"Hello, World!\") # Hello, World! Hello, World!\nprint(str * 2) # Hello, World!Hello, World!\n
"},{"location":"strings.html#string-type-casting","title":"String type casting","text":" str()
- converts any value to a string
casting.rnprint(str(123)) # 123\nprint(str(123.456)) # 123.456\nprint(str(true)) # true\nprint(str(false)) # false\n
"},{"location":"strings.html#string-type-checking","title":"String type checking","text":" is_str()
- returns true
if the value is a string, otherwise false
type-checking.rnprint(is_str(\"Hello, World!\")) # true\nprint(is_str(123)) # false\nprint(is_str(123.456)) # false\nprint(is_str(true)) # false\nprint(is_str(false)) # false\n
"},{"location":"tools.html","title":"Tools","text":""},{"location":"blog/hello-world.html","title":"Hello World","text":""},{"location":"blog/hello-world.html#introduction","title":"Introduction","text":"We are excited to announce the launch Radon - a new open source programming language for the modern world. The language is designed to be simple, fast, and safe while incorporating modern language features such as type inference, pattern matching, and more. A key goal of the language is to be easy to learn and use, while still being powerful enough to build complex applications. It is also designed to be easy to embed in other applications, and to be used as a scripting language. The language is currently in the early stages of development, and we are looking for contributors to help us build the language.
"},{"location":"blog/hello-world.html#about-the-author","title":"About the author","text":"Md. Almas Ali is a software engineer and a programming language enthusiast. He is the creator of the Radon programming language. He has a lot of projects in his GitHub profile. Checkout his GitHub profile for more information.
Created on: 12 Sep 2023 - 2:39 AM (GMT+6)
"}]}
\ No newline at end of file
diff --git a/sitemap.xml b/sitemap.xml
index a2e29cd..4d20af8 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -2,102 +2,102 @@
https://radon-project.github.io/index.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/arrays.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/built-in-functions.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/classes.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/contribution.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/control-flow.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/data-types.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/error-handling.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/file-handling.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/functions.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/input-output.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/installation.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/language-reference.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/loops.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/modules.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/quick-start.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/standard-library.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/strings.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/tools.html
- 2024-06-02
+ 2024-10-27
daily
https://radon-project.github.io/blog/hello-world.html
- 2024-06-02
+ 2024-10-27
daily
\ No newline at end of file
diff --git a/sitemap.xml.gz b/sitemap.xml.gz
index f1dafc5..393c321 100644
Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ