MythLang
MythLang is an Esolang designed by User:PrySigneToFry.
As name shown, this language will be powerful as the myth recounts.
Overview
MythLang is Turing-Complete, and it is "interpreted" language.
Basic syntax
Variable and Data types
This language is static-typed language like Python. In this language, there are 7 data types:
num: A number, range is C. str: A string. bool: A boolean, true or false. array: A list like in Python. pair: A pair of value. One former and one latter. nonetype: Invalid types. lambda: A function.
This is how to define a variable:
name(type) := value
And if you want to make a null variable, use this:
name(type) := declare
Operators
Same as Python, except ^ is used for exponent and ^^ is XOR.
Also, := is assignment and = is equal.
I/O
Output
output something, something, something...
Output a serie of values.
The escaping is same as Python.
Input
input something, something, something...
Input to values. Your input must same as the type of things you want to input.
With format
inputf format, something...
Like scanf in C++ except you wouldn't need to input to address.
Comments
--|| This language only support comment block. ||--
Statements
Conditional statements
if condition {something}
Else is also supported.
if condition {something} else {more_thing}
Elif is also supported.
if condition {something} elseif condition {something} else {more_thing}
Mythlang treat empty values as false(Including false), and others are true.
Looping statements
for iterator in container { do something }
while condition { do something }
do { do something } while condition
Functions
We mostly use lambda as functions. Every code block can be treated as lambda.
After lambda keyword, you write arguments or not. If a lambda have no arguments, treat it as subroutine.
You can assign a lambda to a variable, just like this:
swap(lambda x, y) := { t = x; x = y; y = t; }
Classes
class YourClassName { attributes methods }
self means the self of class. To call an attribute or a method, use a dot.
Examples
Collatz sequences
n(num) := declare; input n; do { output n; if n % 2 == 0 { n /= 2; output f"/2 = {n}"; } else { n = n * 3 + 1; output f"*3+1 = {n}"; } } while (n != 1) output "Done";