Releases: thewhynow/Math-Interpreter
Release list
v1.1.2
range - based for loops have been added!
with syntax borrowed heavily, if not entirely, from python this is what they look like:
for i in [1, 2, 3, 4]{ out(i); } -> 1, 2, 3, 4
you can also use the by keyword to change the order and step
for i in [1, 2, 3, 4] by -1 { out(i) } -> 4, 3, 2, 1
and other minor bugs have been fixed...thats pretty much it for this language I guess. I might revisit this project in the future.
v1.0.3
Strings, if statements, while and for loops, variables, FUNCTIONS, and so much more has been added!
check the code out for yourself, or the syntax.txt file if you need any help.
I am planning on turning this into a full coding language, so please let me know if you have any ideas.
Thanks!
please note that this is a work-in-progress, and there may be bugs from time to time, if there are any, PLEASE let me know!
v1.1.1
The name of this programming language has now been changed to G because of the languages generality
The filetype for this program is now .g
Several bugs have been fixed and a few new things have been added.
-
You are now able to access elements inside a list, no matter how deep:
the code[1, [2, 3]] // 1 // 1is now valid
in addition, you are also able to change said elements inside a list, no matter how deep
[1, [1, 2]] // 1 // 1 =/ 3
the '=/' sign is now used to change the value of any non-variable type -
Classes, or something similar to them have been implemented!
collecs are basically structures in C with a constructor method
some example code:
collec Person = (name, age){out("Person created!");}
The keyword collec is used to specify a collection declaration
The properties specified in the parenthesis are assigned just as they are in C, according to the inputs in the constructorTo create an instance of a collec, you simply run the collec type as a function, passing in the values specified:
bob = Person("bob", 25);->Person created!The constructor runs after a collec is created and the values are assigned
The Person function returns a collec with the values specifiedTo access properties within a collec, you use the
.sign, and to change them you use the=/sign
out(bob.age)->25
bob.age =/ 26->bob.ageis now26
Thats it for now, im planning on adding methods to collecs in the future!
v1.0.2
added support for exponents, through the "^" symbol
ex: 5 ^ 1 = 5
added support for square roots, either through sqrt(value), √(value), or v(value)
sqrt4 = 2
√4 = 2
v4 = 2
above also work with parenthesis
i've also decided on some features that, if this was made into a coding language, the language would include:
==============================================
be able to print a value and assign the value in the same line:
print(a = 1 + 1)
output: 2
==============================================
do this:
if a == b or == c:
same as:
if a == b or a == c:
==============================================
be able to have one for loop iterate through multiple vars / iterators
for a, b, c in range(3), range(3), range(3):
print(a, b, c)
basically the same thing as this:
for c in range(3):{
for b in range(3):{
for a in range(3):{
print(a, b, c)
}
}
}
(brackets used to demonstrate nesting, might be included in the final version)
==============================================
have a goto() function, that tells the interpreter to "go to" the line specified in the function.
0 print(1)
1 print(2)
2 print(3)
3 goto(1)
output: 1, 2, 3, 1, 2, 3...
could also have a second operator that tells the function how many times to "go to" the line. if none is given is assumed to be infinity
0 print(1)
1 print(2)
2 print(3)
3 goto(1, 2)
output: 1, 2, 3, 1, 2, 3
==============================================
math functions such as average, median, and other common stats functions to be performed with a list.
[1, 2, 3].average() = 2
[1, 2, 3].median() = 2
etc...
anything will be able to be converted into an iterator as long as they have a method for converting to a string
a = 123
a = lst(a)
print(a)
output: [1, 2, 3]
etc.
be able to assign booleans through if statements:
a = if 1 == 1
print(a)
output: True
can't think of anything else...
v.1.1.0
A lot of stuff has been added.
Full support for multi-line code with scopes, if statements, functions, while loops, lists, and pretty much any other feature of a regular language has been added.
Note that the language is still very buggy and please notify me if there are any issues!
More info can be found in the README
v1.9.0
Classes, a standard library, improved list syntax, and so much more!
Sorry for holding off on so long, im going to try and cover most of the new features in this post:
- Libraries:
You are now able to import libraries into your code using theusekeyword. The syntax looks like this:use <fileNameAsStringWithType>
A Standard library has been defined. Using it will add new methods to thenumclass, while making no difference on the user end. If the user wants, they can still use primitives.
Eventually I will write all the other primitves out inside the standard library as well. To include the standard library, simply douse "standard.g"
P.S. including a library literally pastes all the code from the library. Here is an example of using the new methods for thenumtype defined in the standard library:
a = 12.345;
out(a.round(2));
out(a.is_integer());
out(a.abs());
these output 12.35, 0, and 12.345 respectively
- Classes:
Methods to classes have been implemented along with some other syntax updates.
By using theset(<identifier>, <value>)function, a variable is able to be kept as a method after the constructor is finished running inside a collec. Here is an example:
collec Person = (name){
set(name, name);
out("Person created!");
}
if we try and access the name property after by doing me = Person("TheWhyNow") and then me.name we would get "TheWhyNow". However, if we did not use the set() function that variable would automatically get deleted. Note that functions defined in a collec bypass this rule and do not need to be marked using the set() function
In addition, changing the properties of a collec is now much easier. instead of previously doing me.name =/ "thewhynow", you can now just do me.name = "thewhynow", which looks much better syntactically.
OVERLOADING METHODS:
you can now overload certain operators with classes in this language. Please check the README for more info, but here is an example number class with the four basic operations overloaded:
collec number = (value){
set(value, value);
func __add__ = (valueB){} -> value + valueB.value;
func __sub__ = (valueB){} -> value - valueB.value;
func __mul__ = (valueB){} -> value * valueB.value;
func __div__ = (valueB){} -> value / valueB.value;
}
# if i try adding two instances of this class, the __add__() function gets called
- Improved List Operations:
instead of indexing with//and changing a value with=/, i have now updated it to use[]and=respectively. Additionally, instead of[]being used to define a list,{}now are used. Here is an example showcasing all of the new improvements:
lst = {1, 2, 3, 4, 5};
lst[0] = 0;
out(lst[0]);
this outputs 0 to the terminal.
There have been many other minor improvements, please check the readme for more info!
Sue me for skipping version numbers >:)
v1.0.1
added support for parenthesis multiplication:
5(5 + 1) now is translated to 5 * (5 + 1)
Working on support for exponents