ix

From Esolang
Jump to navigation Jump to search
ix
Designed by User:Orisphera
Appeared in 2020
Computational class Turing complete
Reference implementation Unimplemented
File extension(s) {{{files}}}
Note that ix is typically lowercased except, often, at the start of a sentence.

Ix is a programming language created by Orisphera. The name is the name of the Latin letter X but also can be understood as the Roman 9.

The language

Ix operates on strings. It has a memory of the type map<string, nonempty_string>. (The map type is similar to Python dict.) The ix program consists of expressions. Expressions can be of 3 types: literal expressions, modified expressions, and compound expressions. A literal expression is either a result of applying the q modifier (see below) to a string (in this case it evaluates to the string to which the q modifier is applied) or the letter i (in this case it reads an undefined amount of input and evaluates to it; it reads when it is evaluated, e. g. rrrEnter something: rorYou entered rico gets the input after outputting "Enter something: "). A modified expression is a literal or compound expression followed by some modifiers. Here are possible modifiers:

  • The h modifier returns the first character of its argument.
  • The t modifier returns its argument without the first character, like Python [1:].
  • The q modifier does the following:
    • Doubles all the "y" characters, except possibly for some of them not followed by one of the characters "nry" or newline. (You can leave it without doubling before a newline if you are not going to replace it.)
    • Puts a "y" character before each "r" character
    • Replaces newlines with the string "yn". You don't have to replace all of them when applying it to get a literal expression, but it's recommended to do so.
    • Views the result as a Python string and applies its join method to the constant string "rr".
  • The g modifier by default always returns an empty string by default, but its behavior can be changed.
  • Identity modifiers always return their arguments but have side effects:
    • <expression>o outputs the result of evaluating the expression.
    • <expression><expression>p evaluates both expressions and modifies the g to return the result of evaluating the second expression for the result of evaluating the first expression.
    • Any character other than cghiopqrtx is an identity modifier with no side effects.

The modifiers are applied left to right. A compound expression is a literal or modified expression followed by a balanced parentheses sequence where the opening parentheses are literal and modified expressions and the closing parentheses are the letters c. When it is evaluated, the literal and modified expressions within it are evaluated and the results are concatenated. The program is pre-processed as follows:

  • It may be cut by the letter x. The part after it is considered comment in this case.
  • If it isn't, ar can be added to the end of the program. If this happens, an error is thrown after the program halts.
  • An even number of the letters r is added to the beginning. For example, rEnter something: rorYou entered rico becomes rrrEnter something: rorYou entered rico.

It is pre-processed in such a way that it can be parsed into expressions. If that is impossible, the behavior is undefined but it is recommended that the program is published here. The execution goes in cycles. Each time all the expressions in the program are evaluated. Then, if the program was not terminated with the letter x (including the case when it throws an error), it halts. Otherwise, a new program is constructed as follows: the q modifier is applied for the values of all except the last expressions, and then the results are concatenated together with the result of the last expression. The interpreter doesn't have to pre-process, then parse, and then execute the program. It can or can not do these things simultaneously depending on the implementation.

Case-sensitivity

In the very first edit, it is said that ix is case-insensitive. That was a mistake. It can be case-sensitive, case-insensitive or partially case-sensitive (probably like URL) depending on the implementation.

Samples

Hello, World!

rHello, World!ynro

Quine

The following program was in this section. I think I made a mistake when designing it because it doesn't seem to work.

ryryrgqyryrgcoorrrgqrrgco

Here is a fixed version:

rpgqyryrgcorpgqrrgco

Infinite loop

rgxrpgx