or

From Esolang
Jump to navigation Jump to search
or
Paradigm(s) Imperative/String-rewriting
Designed by Fungot
Appeared in Unknown year, 14:00 ~ 14:01
Computational class Finite-state automaton
Reference implementation N/A
Major implementations Python
File extension(s) .txt

or is an esoteric programming language mentioned by Fungot on 14:00, with an unknown date. It is unknown how long in development was this language before being published. It is an implemented finite-state automaton, that has one instruction. "or" is not to be confused with the logical or, which is simply an operator.

IRC Log

Given below is all the information currently available as a raw IRC log. If you happen to be around when fungot leaks more information please extend this article.

14:00 < mroman_> fungot: Fnordy morning to you
14:00 < fungot> mroman_: what's the rationale for that? they need more of this silliness? :) i don't know squat about the language
14:00 < mroman_> fungot: I know the language.
14:00 < fungot> mroman_: but i don't
14:00 < mroman_> fungot: Shall I teach you?
14:00 < fungot> mroman_: is that or?
14:01 < mroman_> fungot: Yeah, the language is called 'or'.
14:01 < fungot> mroman_: the command to push false is ' f'
14:01 < mroman_> fungot: Exactly. To push false to the stack in 'or' you just use the f command prefixed with a space.

Description

or has a stack, but no tape or queues, instead taking a more dynamic approach to output and calculations. Rather than using a set of instructions to control the program flow, the execution order is always the same and straight forward. There is no way to define a variable or a data-structure, and the source code is exactly what the computer will do, which is a concept many find hard to grasp.

There is only one instruction, if you can call it that, —  f. It has very interesting properties which make quines and such very easy to write, but more on that later. Anything that isn't this instruction is either ignored, or in some implementations causes an error. Case sensitivity is also up to the implementation to decide, as it's unspecified by original author. The only thing we can say for sure is that the standard syntax is supposed to have both letters lowercase.

or has no way to input things, no STDIN libraries, no way to read an external file, or even a command-line input. While this is problematic, it has its advantages. For example it is easier to write implementations, because the source code can be taken as input.

Syntax

Instruction Arity Function Size Added in Removed in Alternative syntax Notes
 f 0 Push false onto the stack 2 bytes version: 1.0 -- -- Required in all implementations.
<Anything else> -- Do nothing. Any size -- -- -- In some implementations can cause an error.

 f is an instruction, not a pattern, so:

 f 

Will push false, not false false , because there is only one pair of space and f's.
Spaces or newlines aren't required after an instruction, but that means they aren't ignored either. For example:

 f f f
 f Example
f
f

Will push: false false false false , because the fifth pair of spaces and f's was divided by a newline.

f

Instruction  f has many interesting properties. First one being: It pushes a superset of the same characters needed to create itself. In other words: every or program made out of entirely instructions or will be a quine.

Because of that, you can think of an or program not as source code for a computer to execute, but rather some order of characters that will be filtered to contain only f. That would make dd a string-rewriting paradigm instead of an imperative language.

Second interesting property, not really related to the instruction  f, is that every other character acts as a NOP, which makes this language very good option for writing polyglot programs.

Computational class

Computational class is finite-state automata, because it can't reach an infinite amount of states without an infinite source code.

Examples

Push "false "

Push f.

Golfed:

 f

Quine

 f

Polyglot iterating quine (2 languages)

 f

Works in Text and or.

Test programs

Expects 2 falses on the stack

 m f ma f

Expects 1 false on the stack

 f a lf 

Expects 2 falses on the stack

a f fa

Implementations

  • Talk:Or has 4 implementations in different languages.

Python

def run(p):
    i = 0
    stack = []
    while i < len(p):
        if p[i] == " ":
            i += 1
            if p[i] == "f":
                stack.append(False)
        i += 1
    return stack

print(run(" f"))
Case sensitive? Does everything except " f" cause an error? Newlines ignored?
Yes No No

Keg one-liner

?( =[f=[0.
Case sensitive? Does everything except " f" cause an error? Newlines ignored?
Yes In special cases No

RegExr Regex Expression

 [fF]

Use it here

Case sensitive? Does everything except " f" cause an error? Newlines ignored?
No No Dubious

See also