OEIScript
OEIScript is an esolang created by User:TriMill in 2021. The only way to manipulate data is using sequences from the OEIS. This makes it very hard to perform simple binary operations (ex. addition, multiplication), while complex unary operations (ex. factorial, Fibonacci) are very simple.
Syntax
OEIScript programs are made up of a series of lines separated by line breaks. Comments begin with a # and continue until a line break.
To import a sequence from the OEIS, write the desired name, followed by a colon, followed by the sequence's ID.
MySequence: A000027
Sequences are by convention written in UpperCamelCase
. It is best to fetch all sequences at the beginning of the program, and avoid fetching sequences inside of loops.
To assign a value to a variable, use an equals sign. Integer variables are by convention written in lowerCamelCase
.
n = 5
Variables may either contain an integer, a sequence, or null. All variables are initialized by default to null, this can be done manually by omitting the value after the equals sign.
n =
To use a value as an index into a sequence, write the sequence's name before the value or variable.
i = MySequence 3 # get the 3rd element of MySequence
j = MySequence i # get the 'i'th element of MySequence
Sequences can be chained, the value at the end is send backwards through each sequence in order.
m = ThirdSeq SecondSeq FirstSeq 3
IO is only possible on numbers.
User input is taken by adding ? after a variable. EOF will result in a null variable.
x?
For output, use ! in front of a value, variable, or chain of sequences.
! 5
! x
! MySequence 3
Blocks are used for control flow. The statements between the curly braces will run as long as the variable preceding the block is not null. Blocks can be nested.
var = 1 var { # Get the "var"th element of MySequence and store the result back in var, repeat until var is null (when MySequence does not contain a value at var) var = MySequence var }
Implementation details
Integers must be at least as large as the largest number in the OEIS (which at the time of writing is over 2^945), so unbounded integers are best. Sequence IDs that are not valid ("A" followed by some digits) should raise an error, but valid unregistered sequences should return a sequence of all nulls. Invalid indices (out of bounds, null, or another sequence) should result in null. Attempting to print a non-integer should display nothing. If the input is not an integer, an error should be raised.
Examples
Cat
x? x { !x x? }
Truth Machine
# This can probably be simplified to require fewer sequences, # but finding ones with the right properties is hard Ints: A000027 NegOne: A033999 Id: A007953 x? a = x x { !a x = Id NegOne Ints x }
99 Bottles
# A000027 only goes up to 77, so another sequence must be used to get the rest of the integers Ints1: A000027 Ints2: A053738 Bottles: A096582 x = 1 x { ! Bottles x x = Ints1 x } x = 36 x { ! Bottles Ints2 x x = Ints1 x }
Hello World
HelloWorld: A117845 Ints: A000027 x = 0 a = 0 a { a = HelloWorld x x = Ints x ! a }
Useful sequences
The following OEIS sequences can be used in a lot of cases. Keep in mind that these are all fairly short and only work for nonnegative integers, so extra work is needed to operate with large numbers.
Computational class
OEIScript is not Turing complete, since the total possible storage is bounded (programs may only contain a finite number of variables, and while integers can be unbounded the number of possible values is limited to those in the OEIS and any literals in the program itself). Beyond that, its computational class is unknown.
Implementation
Implementation in Python: OEIScript/implementation.py