Isomorphism
- This is still a work in progress. It may be changed in the future.
- For the concept in mathematics, see wikipedia:isomorphism.
Designed by | PSTF |
---|---|
Appeared in | 2024 |
Computational class | High-level, Pseudonatural |
Reference implementation | Unimplemented |
File extension(s) | .ism |
Isomorphism is an esoteric programming language that was invented by User:PrySigneToFry upon reading Isomorphism: The mathematics in programming.
It is inspired from Haskell and Python, and other a lot of programming languages. This is no joke.
Syntax
Assignment, variables and constants
Assign a variable to a specified value:
var -> type = value
Change the value of variable:
var = value
Initialization:
Constant
data name -> type = value, const = true
Variable
data name -> type = value, const = false
Number
You can define the number like these:
zero one two ... ten eleven ...
And you can use succ
to get a successor of any data, and use pre
to get a previous of any data.
So you can define the set ℕ by these code:
data Nat -> int = zero \\ succ Nat
I/O
Input
Normal
input(var)
With prompt
input(var, __prompt = "")
Output
Normal
print(*args)
With end sign
print(*args, end = "")
Another unique way (output variables only)
- Take only one variable
output var
- Take an element from a list
list !! elem_num
- Take a part from a list
take (start, )end(, step) from list
If-state
Only if state
if expr then: code fi
If-else state
if expr then: code1 else: code2 fi
If-elif-else state
if expr1 then: code1 elif expr2 then: code2 --snip-- else: codeN+1 fi
Loops
For loop
for(init; cond; incr) code fi
While loop
while(expr) code fi
Function
Define a function
type func name(*args, **kwargs) function_body end
Object
Define an object and invoke it
class objName(superclass) attrib void static __init__(self) initialization end other statics end data var -> objName var.staticName()
Mathematical and Logical
Mathematics
Define the mathematical calculations
a + zero = a a + succ b = succ a + b a * zero = zero a * succ b = a * b + a a ^ zero = one a ^ succ b = a ^ b * a a - b = a + negate(b) a / b = a * recipr(b) a // b = floor(a / b) a% of b = b / 100 * a mod(a, b) = a - (b * (a // b)) root(a, b) = a ^ recipr(b) sqrt(a) = root(a, two) cbrt(a) = root(a, three) qdrt(a) = root(a, four) log(a, b) = x if a ^ x == b log(a, a) = one log(a, one) = zero log(a, zero) = negate(infinity) negate(zero) = zero negate(succ a) = pre negate(a) recipr(a) = a ^ negate(1) max(a, b) = a if a > b else b min(a, b) = a if a < b else b
LOGICAL
Define logical and binary calculation
p = {0, 0, 1, 1} q = {0, 1, 0, 1} p and q = {0, 0, 0, 1} # The result is true only if both logical values are true. p or q = {0, 1, 1, 1} # As long as one of the two logical values is true, the result is true. not p = {1, 1, 0, 0} # When a logical value is negated (NOT gate), the true becomes false and the false becomes true. yes p = {0, 0, 1, 1} # A logical value will remain as it is and output after passing through the YES gate. p nand q = not (p and q) p nor q = not (p or q) p xor q = {0, 1, 1, 0} # When two logical values are DIFFERENT, the result is true. p nxor q = not (p xor q)
Define comparison
a > b if succ a > succ b a < b if b > a a == b if succ a == succ b a ~= b if not (a == b) a >= b if not (a < b) a <= b if not (a > b)
More syntax
See Isomorphism/More Syntax for more details.
Example
Hello, world!
print("Hello, world!")
A+B Problem
data a -> int data b -> int input(a) input(b) data c -> int = a + b output c