A program
Save text as name.cbt and pass the path. A program error exits with status 1 and a line beginning Beta behavior detected.
Version 1.2 · MIT License · Python 3.10+
Cobratate is an esoteric imperative language. The vocabulary is borrowed from a public persona. The evaluation rules are those of a small teaching language: names, arithmetic, conditionals, loops, functions, and lists. The interpreter is one Python file. The manual is organised like a language reference.
Er. Rishabh Aryan
M.Tech student in Artificial Intelligence and Data Science, Department of Computer Science and Engineering, Indian Institute of Information Technology, Bhagalpur. Cobratate was written during a hackathon at the Indian Institute of Technology Jammu, in the course of an internship there. The repository holds the interpreter, the manual, and the programs added so the claim of a working language can be checked. No prize is claimed for that session.
Python 3.10 or newer is required. If python is missing, use python3 on macOS or Linux, or py on Windows. A ZIP download from the repository works if Git is not installed.
$ git clone https://github.com/Rishabh-bgp/cobratate.git $ cd cobratate $ python cobratate.py --version $ python cobratate.py examples/intro/hello.cbt $ python cobratate.py -c "WHAT COLOR IS YOUR BUGATTI 21 PLUS 21" $ python cobratate.py
Save text as name.cbt and pass the path. A program error exits with status 1 and a line beginning Beta behavior detected.
Quotes depend on the shell. A wrong command line exits with status 2. A missing file is reported on the standard error stream.
The prompt is topg>. A line that opens a block waits for PERIOD, STOP GRINDING, or DONE HUSTLING. :quit leaves.
A program is enclosed by ESCAPE THE MATRIX and BACK TO THE MATRIX. MATRIX: starts a comment. When the manual and cobratate.py disagree, the interpreter is the specification.
| Form | Meaning |
|---|---|
WHAT COLOR IS YOUR BUGATTI expr | Print the value and a newline. |
BUGATTI name EQUALS expr | Bind a name in the current environment. |
IF expr THEN … OTHERWISE YOU ARE A BETA … PERIOD | Conditional. The otherwise-branch may be omitted. |
GRIND WHILE expr … STOP GRINDING | Loop while the test is sigma. ESCAPE THE GRIND leaves it. |
HUSTLE name WITH a AND b … DONE HUSTLING | Define a function. CASH OUT expr returns. |
CALL name (expr, expr) | Call. The parenthesis ends the argument list, so a following operator is not swallowed. |
ASK THE MATRIX | Read one line. ASK THE MATRIX FOR A NUMBER reads a number. |
[expr, expr] | A list, called a garage. PLUS concatenates garages and repeats text. |
CALL put (garage, index, value) | A new garage with one index replaced. The original is not modified. |
Numbers, text, the booleans SIGMA and BETA, and garages. CALL kind reports which. Comparisons and arithmetic do not coerce text.
DIVIDED BY is real division, and an exact whole result stays an integer. SPLIT BY is floor division. MODULO is remainder.
A grind stops after one million turns. A call stops after one thousand nested hustles. An error names the line and, inside a call, the hustle stack.
Built-ins: length, absolute, floor, at, piece, put, kind, text, number, min, max. There are no classes, modules, files, or a network library.
Twenty files, each run with no input. A stack is a garage whose last element is the top. A queue is a garage whose first element is the front. A graph is a garage of neighbour garages. The learning programs use ordinary arithmetic, not a numerical library.
| Program | What it shows |
|---|---|
| hello.cbt | Print. |
| grind.cbt | Assignment and a compounding loop. |
| fizz.cbt | FizzBuzz as COBRA, TATE, and COBRATATE. |
| hustle.cbt | Functions, booleans, and string repeat. |
| garage.cbt | Lists, indexing, kind, and number conversion. |
| Program | Checked behaviour |
|---|---|
| primes.cbt | Trial division for primes below 50. |
| euclid.cbt | Greatest common divisor 42 and least common multiple 252. |
| collatz.cbt | Hailstone steps and peak. |
| fib.cbt | Recursive Fibonacci. |
| binomial.cbt | Pascal's triangle. |
| bases.cbt | 42 in base 2 is 101010. |
| Program | Algorithm | Checked result |
|---|---|---|
| bubble.cbt | Bubble sort | [5, 1, 4, 2, 8, 0] becomes [0, 1, 2, 4, 5, 8]. |
| search.cbt | Linear scan and binary search | 9 is at index 4. 8 is absent and returns −1. |
| stack.cbt | Push, top, and pop | After three pushes and one pop, [10, 20]. |
| twosum.cbt | Pair of indices | [2, 7, 11, 15] and target 9 give [0, 1]. |
| bfs.cbt | Breadth-first search | [[1, 2], [3], [3], []] from 0 visits [0, 1, 2, 3]. |
| Program | Model | Checked result |
|---|---|---|
| regression.cbt | Univariate linear regression, 200 steps | On y = 2x, the weight is about 1.99 and x = 5 predicts about 9.98. |
| perceptron.cbt | Perceptron on AND | The four inputs classify as 0 0 0 1. |
| knn.cbt | One-nearest neighbour | [2, 2] is class 0. [5, 6] is class 1. |
| normalize.cbt | Min-max scaling | [10, 20, 30] becomes [0, 0.5, 1]. A constant column becomes zeros. |
A first program through lists.
Tokens, values, statements, scope, and limits.
Argument counts and the errors for a wrong call.
Every example and the result it was checked against.
The messages the interpreter raises.
The phrases, and the allegations stated as allegations.
Universities, colleges, and schools
The MIT License already permits an institution to copy the interpreter and the manual, distribute them to a class, and modify them for a course, provided the copyright notice and license terms stay with the copy. No separate permission is required. The recommended place is an early laboratory or a one-week interlude, not a replacement for a production language. A department that adopts it should also say that the persona is controversial.