m==

From Esolang
Jump to navigation Jump to search

m== is an esoteric programming language by User:A inspired by This=That. This programming language tries to represent 6 conditional operators using only 1 operator.

Syntax

& "this is a comment" The & operator takes a string and ignores it. It works like a comment.
= Set a variable to a value.
print Output a variable.
input Set the variable "input" as input.
+, -, *, and / Do math, like
x=4
Jerome=x-2

sets x as value 4 and Jerome as value 2 (4-2). Also:

fruit="fly"
printer="paper"
sticky=fruit+printer

sets fruit as value fly, printer as value paper, and sticky as value flypaper (word math only works with plus).

Note that if you try to do math on strings using -, *, or /, the strings will be converted to its hash value.

if exp {things_to_do} execute "things_to_do" if exp is true.
while exp {things_to_do} execute "things_to_do" until exp is false.

Conditions

Conditions support only one operator, which is the m== operator.

& "m== a b c"
& "evaluate the maximum value of a and b. Return true if the value is equal to c. Otherwise, return false."
& "Works like:"
if m== 12 13 13
{
    a="success"
    print a
}

How to implement other conditionals in if statements:

& "a==b"
if m== a b a
{
    if m== a b b
    {
         & "a==b"
    }
}
& "a!=b"
flag=true
if m== a b a
{
    if m== a b b
    {
        flag=false
    }
}
if m== flag true flag
{
    if m== flag true true
    {
        & "a!=b"
    }
}
& "a>b"
if m== a b a
{
    & "a>b"
}
& "a<b"
if m== a b b
{
    & "a<b"
}
& "a>=b"
flag=true
if m== a b a
{
    flag=false
}
if m== flag true flag
{
    if m== flag true true
    {
        & "a>=b"
    }
}
& "a<=b"
flag=true
if m== a b a
{
    flag=false
}
if m== flag true flag
{
    if m== flag true true
    {
        & "a<=b"
    }
}

Computational Class

You can translate This=That programs easily into this programming language, so it is Turing-complete.