Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Releases: MathScript-Lang/MathScript.py

MathScript v1.0.1

09 Aug 17:45
Compare
Choose a tag to compare

Added

  • return keyword in multi-line functions to return a value
  • continue keyword to skip to the next iteration in for and while loops
  • break keyword to stop the loop in for and while loops
  • exec() function to execute a code in a string or a file
  • length() function to return the length of a string or a list
  • Comments starting by the # symbol and ending by a new line.

Changed

  • The list concatenation, so now we need to add two list together to concatenate them:
    (MathScript) >>> (1, 2, 3, 4, 5) + (6, 7, 8, 9, 10)
    (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    
    instead of the old confusing syntax where we needed to add the element to the list:
    (MathScript) >>> (1, 2, 3, 4, 5) + 6 + 7 + 8 + 9 + 10
    (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    
  • Create automatically the ZIP file in the build process & always undo the changes to the shell.py script, altrough if there was an error.

Fixed

  • Now functions that only execute code will return null (instead of Python's None), but this won't be shown in the interactive shell because it's an implicit return.

Next version changes

In the next minor versions of MathScript will be implemented these changes:

  • A class & modules system
  • Instance functions for the built-in data-types
  • (Not sure) A package manager, MathGet

Installer

Added

  • An update feature to be able to update MathScript without having to uninstall & reinstall it completely
  • Now there's also an AppImage version of the installer, for Linux.
  • Now uses threads for downloading, unzipping and uninstalling

Fixed

  • Since the installer accept now the fact that you can don't update, the repair feature now reinstall the current installed version
  • Now the icon size range from 16×16 to 256×256, instead of the only 16×16 icon of before

MathScript v1.0.0

02 Aug 00:17
Compare
Choose a tag to compare

⚠️ Always download the installer from the latest release ⚠️


Notes

The comments in the code are just placeholders, MathScript v1.0.0 doesn't support comments.

1. Basic Syntax

  • Case Sensitivity: MathScript is case-sensitive.
  • Keywords: MathScript utilizes keywords for control flow and function definition. Keywords are:
    • and
    • or
    • not
    • if
    • elif
    • else
    • for
    • to
    • step
    • while
    • func
    • then
    • pass
    • end
  • Identifiers: Identifiers are used to name variables and functions. They can contain letters, digits, and underscores (_), but cannot start with a digit.
  • Comments: Comments are not supported by MathScript v1.0.0.

2. Data Types

MathScript supports the following data types:

  • NullType: none, null or undefined.
  • Boolean: true or false.
  • Integer: Whole numbers (e.g., 1, 2, -5).
  • Decimal: Numbers with decimal points (e.g., 1.5, -2.75).
  • Complex: Numbers with real and imaginary parts (e.g., 2+3i, -4-1i). Note: i is used for the imaginary unit.
  • String: Sequences of characters enclosed in double quotes (""), single quotes (''), or backticks (``) (e.g., "Hello", 'World', `\ This is a raw string`).
  • List: Ordered collections of values enclosed in parentheses () (e.g., ('Bob',), (1, 2, 3)).
  • Function: User-defined functions.
  • BuiltInFunction: Built-in functions.

3. Operators

MathScript supports various operators:

  • Arithmetic:
    • + (addition)
    • - (subtraction)
    • * (multiplication)
    • / (division)
    • ^ (exponentiation)
  • Comparison:
    • == (equals)
    • != (not equals)
    • < (less than)
    • > (greater than)
    • <= (less than or equal to)
    • >= (greater than or equal to)
  • Logical:
    • and (logical AND)
    • or (logical OR)
    • not (logical NOT)
  • Subscript:
    • _ (subscripting for strings and lists, when using it with variables enclose the variables in parenthesis like this: (lst)_(index))
  • Function Call:
    • ( ) (function invocation)
  • Assignment:
    • = (assigns a value to a variable)
  • Inline function Definition:
    • => (defines the return value of a function)

4. Control Flow

MathScript includes the following control flow statements:

  • if statement:

    if condition then if_true else _else
    
    if condition then
        # Code to execute if condition is true
    else
        # Code to execute if condition is false
    end
    
  • elif statement:

    if condition then if_true elif another_condition then if_other_true else _else
    
    if condition then
        # Code to execute if condition is true
    elif another_condition then
        # Code to execute if another_condition is true
    else
        # Code to execute if neither condition is true
    end
    
  • for loop:

    for variable = start to _end step _step then iteration # => (iteration1, iteration2, ...)
    
    for variable = start to _end step _step then
        # Code to execute in the loop
    end
    

    step value is optional, and defaults to 1.

  • while loop:

    while condition then iteration # => (iteration1, iteration2, ...)
    
    while condition then
        # Code to execute in the loop
    end
    
  • func function definition:

    func function_name(arg1, arg2 = value) => return_value
    
    func function_name(arg1, arg2 = value)
        # Code to execute in the function
    end
    

    Function definition supports optional arguments with default values.

5. Built-in Functions

MathScript offers built-in functions:

  • print(): Prints value to the console. Accepts sep and end_char arguments for formatting.
  • input(): Takes input from the user. Accepts placeholder argument for prompting.
  • clear(): Clears the console.
  • exit(): Exits the program. Accepts code argument for exit code.
  • type(): Returns the type of an object as a string.
  • sin(): Returns the sine of an angle (complex numbers supported).
  • cos(): Returns the cosine of an angle (complex numbers supported).
  • e: A constant representing the value of e.
  • pi: A constant representing the value of pi.
  • inf: A constant representing positive infinity.
  • nan: A constant representing 'Not a Number'.

6. Execution

A MathScript program is executed using the mathscript command.

  • mathscript <your_program.mscr>: Executes a .mscr file.
  • mathscript: Starts an interactive shell.