Introduction
What is ArrEx
ArrEx is a shorthand programming language for Python that allows for easy manipulation of arrays. Some notable features are arithmetic operators, array looping, conditional statements, sorting, regex, and customizable functions.
Installing ArrEx
ArrEx can either be installed through Github or through Pip
pip install ArrayExpressions
Getting Started
The main function that will be used is evaluate
from ArrayExpressions import arrex
lst = [1, 2, 3, 4, 5]
output = arrex.evaluate(lst, "e(x + 1)")
print(output) # [2, 3, 4, 5, 6]
In this code, 'evaluate' will run the code, passing in lst to the scope (represented by 'x'). So, at the beginning of the code, x will equal [1, 2, 3, 4, 5]. In this language, certain functions like e() create a new scope. Essentially, e() loops through each element of the x in scope. So, it loops through the list, and sets the scope of x inside of it to the current element. Look at the table below for a step by step.
Step | X | Code | Return | Comments |
---|---|---|---|---|
1 | [1, 2, 3, 4, 5] | e(x+1) | Nothing returned yet | |
2 | 1 | x + 1 | 2 | Uses the first element and adds to it |
3 | 2 | x + 1 | 3 | Pattern continues |
4 | 3 | x + 1 | 4 | |
5 | 4 | x + 1 | 5 | |
6 | 5 | x + 1 | 6 | |
7 | [1, 2, 3, 4, 5] | [2, 3, 4, 5, 6] | [2, 3, 4, 5, 6] | The code 'e(x+1)' was replaced with an array |
What's Next
To continue learning, you can use the arrows on the bottom or press the button in the top left which will give a list of every page. To use it, refer to the installation section on this page. Finally, you can support this project by starring ⭐ the repository on Github!