Insanity

From Esolang
Jump to navigation Jump to search

Insanity is an esolang conceived by User:PythonshellDebugwindow and finalized by User:A. It’s based on Einstein’s definition of insanity—doing the same thing over and over again and expecting a different result.

Program structure

The whole program is wrapped in an infinite loop, because in the body of the infinite loop the same thing is repeated over and over again. However, since there are mutable variables, you can expect a different result on every iteration of the loop, making you at least partially sane.

In the first line a set of variables is defined and is assigned to a specific value. Different variables are separated with commas. E.g.

1,1+2,5

They are assigned to a, b, and c, respectively. All assignable variables are a-z and A-Z, and operators are + - * /.

In the remaining lines an infinite loop is set to iterate these variables.

Example programs

Fibonacci sequence

0, 1
b, a+b

Factorial

The following program generates the factorial n! for each n ≥ 1, storing the result n! in the variable a, while the variable b maintains the multiplicand n + 1 for the next cycle.

1, 2
a * b, b + 1

Counter

This simple program counts from one (1) up to infinity, storing each result in the variable a:

1
a+1

Interpreter

  • Common Lisp implementation of the Insanity programming language.