Xonovile

From Esolang
Jump to navigation Jump to search

Xonovile is designed by PSTF.

It uses pictograms as commands, to let the program understandable.

Overview

Xonovile is Turing-Complete, has I/O manipulation and functions(including R&R).

Also known as "×∘⊓⍜⋁|L⋶".

Command Set

Comments

Things between .# and #> will be ignored.

Arithmetic

A plus sign means addition, append or concatenate.

  • For x + y,
    • If both x and y are numbers, they're added together.
    • If x is list and y is another element(must be string literal if x is string literal), it means to concatenate y to the tail of x.
    • If both x and y are ordered pairs, let x = (a1, b1) and y = (a2, b2), then x + y = (a1 + a2, b1 + b2). Also suitable for if both x and y are complex numbers(Real numbers can be treated as complex numbers that has an imaginary part of 0. Complex numbers are formed by a + bi, where 1i is not equal to i).

A subtraction dash means subtraction. It only exist when both x and y are numbers, ordered pairs, or complex numbers.

A "×" means multiplication.

  • For x × y,
    • If both x and y are numbers, the result is multiply x by y.
    • If x is list/string literal and y is number, x is repeated for y times.
    • If both x and y are ordered pairs, let x = (a, b) and y = (c, d), then x × y = (ac - bd, bc - ad). Also suitable for if both x and y are complex numbers.

A "÷" means float division. Only exist when both x and y are numbers, ordered pairs, or complex numbers. If x = (a, b) and y = (c, d) then x ÷ y = ((ac + bd) ÷ (c² + d²), (bc - ad) ÷ (c² + d²)) where (c, d) ≠ (0, 0).

A slash means truncated division. It first get the result of x ÷ y, then round it towards 0. Use backslash for modulo.

An ASCII-circumflex means exponent.

  • For x ^ y,
    • If y can be represented by a ÷ b,
      • If b is even, then for x which is below 0, return √|x| · i.
    • If y is 0, then ignore x and return 1.
    • If x is complex number that can be represented by a + bi, let r = a² + b², and convert x into r(cos(θ) + i sin(θ)) where θ = tan-1(b ÷ a), return rn(cos(nθ) + i sin(nθ)).

y√x is the shorthand of x^(1 ÷ y). If y = 0 then return NaN.

log_y(x) returns k if yk = x.

A list is represented by elements wrapped in bracket and seperated by comma.

Assign and I/O

An arrow pointed left means assignment.

Assign to ⎕ (I call it quad, just like APL) means STDOUT and EVLIN(evaluated input).

Assign to ⍞ (Quad apostrophe) means MSGOUT(Pop-up window) and STDIN.

Assign to ⌺ (Quad lozenge) means STDERR, which output error message. If it's ⌺* then it means debug message.

Assign to ⌧ (Eraser) means to delete the variable.

Conditional Jump/Loop and Iterating Loop

∗label_name: defines a label, and ⇱label_name means to jump to the label.

y?x:z is a simplest if-else statement. y1?x1:y2?x2:z is if-elif-else statement. Leave z blank means that no "else" block.

All commands are seperated by semicolons if they're in one line. Use brace to wrap command together into a code block.

y?`x is a while statement.

From left to right, ∧∨¬⊻ means AND, OR, NOT and XOR.

a∈A returns if x is the lement of 𝔸, and A⊂B returns if 𝔸 is a subset to 𝔹.

↓a∈A{t} is same as this in Python:

for a in A:
    t

⌈x⌉ is round x away from 0 and ⌊x⌋ is round x towards 0. _[[x]]_ is round as usual. .|x|. is absolute value.

= is equal, ≠ is not equal, < is below, ≤ is not above, > is above, ≥ is not below.

⊨ is true and ⊭ is false.

Data Types

Xιn means to return nth element(count up from 0 but -1 means last and -2 is second-to-last and so on) from the X. If n ≥ X.length or n < -X.length then return error. We try to avoid using Latin letters as commands whenever possible.

⍰𝕏 means to grab out a random element from 𝕏. ℂ, ℕ, ℚ, ℝ, and ℤ are reserved for Complex numbers, Natural numbers, Rational numbers, Real numbers, and Integers. Do not convert them into numbers. If you really did that, ℝ, ℤ and ℚ will return ℵ0, ℝ is ℵ1 and ℂ is ℵ2. ℵ0 is used as infinity and has a short hand of ℵ0 or even just ∞.

ρabc will generate a range with the start value of a(including), end value of b(including if c can divide b else excluding) and a step of c.

“XXX” is a string. Use ⎋ as escaping, such as ⎋“ is “ and ⎋n is newline. ⎋⎋ means the character ⎋.

〖〖〖XXX〗〗〗 is a document that didn't support ⎋ as escaping but is multi-lined.

(XXX)#{$k} is a number in base k. If k is below 1 or above 64, throw an error. Base-1(or Marchal, or maybe Unotial) is just to count how many zeroes are there in the parentheses and reduce the value by 1.

The types are quoted in .{{}}.. We have these types:

  • Numbers.
  • Complex numbers.
  • String literals.
  • Lists.
  • Booleans.
  • Ordered pairs.
  • NULL values.

Σ𝕏 means to sum up all elements in 𝕏. If 𝕏 is a list of string literals, concatenate them together according to the real index instead of dictionary-style order.

∪ represents joining two lists together and removing duplicate elements (keeping only one) to form a new list, while ∩ represents forming a list of elements that are common to both lists.

Functions

In this programming language, we call a function "lambda", although this language has nothing to do with Lambda calculus.

To define a function, we use λ.[argument_list]{code_block}, very similar to Lambda calculus.

You can also assign a variable with lambdas, just like this:

fibonacci ← λ.[x.{{num}}.]{(x < 0)?{↺NaN}:(x = 0)?{↺1};↺(fibonacci(x - 1) + fibonacci(x - 2))};
x ← ⎕; ⎕ ← fibonacci(x);

More commands

Coming soon in future versions.

Example Programs

Hello, world!

⎕ ← “Hello, ×∘⊓⍜⋁|L⋶!”;

A+B Problem

a ← ⎕
b ← ⎕
⎕ ← (a + b)

Fibonacci

See above.

Or, how about a slightly more obvious version?

fibonacci ← λ.[x.{{num}}.]{
    (x < 0)?{
        ↺NaN}
    :(x = 0)?{
        ↺1};
    ↺(fibonacci(x - 1) + fibonacci(x - 2))
};
x ← ⎕; ⎕ ← fibonacci(x);

Factorial

x ← ⎕; ⎕ ← x!;

Truth Machine

x ← ⎕;
⎕ ← x;
x?`{⎕ ← x;};

Cat program

x ← ⍞;
x?`{
    ⎕ ← x;
    x ← ⍞;
};

Categories