Version 1.2 · MIT License · Python 3.10+

What color is your Bugatti?

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.

Cobratate emblem: a cobra within a gold ring
1.2Current language version
20 programsChecked examples in four groups
No packagesInterpreter is cobratate.py
MITClassroom copying is already permitted

Creator

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.

GitHub · ORCID 0009-0004-7595-9440 · Origin note

Install and run

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.

repository rootthree forms
$ 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
File

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.

-c

One statement

Quotes depend on the shell. A wrong command line exits with status 2. A missing file is reported on the standard error stream.

No argument

The loop

The prompt is topg>. A line that opens a block waits for PERIOD, STOP GRINDING, or DONE HUSTLING. :quit leaves.

Language

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.

FormMeaning
WHAT COLOR IS YOUR BUGATTI exprPrint the value and a newline.
BUGATTI name EQUALS exprBind a name in the current environment.
IF expr THEN … OTHERWISE YOU ARE A BETA … PERIODConditional. The otherwise-branch may be omitted.
GRIND WHILE expr … STOP GRINDINGLoop while the test is sigma. ESCAPE THE GRIND leaves it.
HUSTLE name WITH a AND b … DONE HUSTLINGDefine 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 MATRIXRead 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.
Values

Four kinds

Numbers, text, the booleans SIGMA and BETA, and garages. CALL kind reports which. Comparisons and arithmetic do not coerce text.

Arithmetic

Exact when it can be

DIVIDED BY is real division, and an exact whole result stays an integer. SPLIT BY is floor division. MODULO is remainder.

Limits

Fail closed

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.

Programs

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.

Introduction

ProgramWhat it shows
hello.cbtPrint.
grind.cbtAssignment and a compounding loop.
fizz.cbtFizzBuzz as COBRA, TATE, and COBRATATE.
hustle.cbtFunctions, booleans, and string repeat.
garage.cbtLists, indexing, kind, and number conversion.

Numerical

ProgramChecked behaviour
primes.cbtTrial division for primes below 50.
euclid.cbtGreatest common divisor 42 and least common multiple 252.
collatz.cbtHailstone steps and peak.
fib.cbtRecursive Fibonacci.
binomial.cbtPascal's triangle.
bases.cbt42 in base 2 is 101010.

Data structures and algorithms

ProgramAlgorithmChecked result
bubble.cbtBubble sort[5, 1, 4, 2, 8, 0] becomes [0, 1, 2, 4, 5, 8].
search.cbtLinear scan and binary search9 is at index 4. 8 is absent and returns −1.
stack.cbtPush, top, and popAfter three pushes and one pop, [10, 20].
twosum.cbtPair of indices[2, 7, 11, 15] and target 9 give [0, 1].
bfs.cbtBreadth-first search[[1, 2], [3], [3], []] from 0 visits [0, 1, 2, 3].

Machine learning

ProgramModelChecked result
regression.cbtUnivariate linear regression, 200 stepsOn y = 2x, the weight is about 1.99 and x = 5 predicts about 9.98.
perceptron.cbtPerceptron on ANDThe four inputs classify as 0 0 0 1.
knn.cbtOne-nearest neighbour[2, 2] is class 0. [5, 6] is class 1.
normalize.cbtMin-max scaling[10, 20, 30] becomes [0, 0.5, 1]. A constant column becomes zeros.

Manual

Start

Tutorial

A first program through lists.

Rules

Reference

Tokens, values, statements, scope, and limits.

Catalogue

Programs

Every example and the result it was checked against.

Diagnostics

Errors

The messages the interpreter raises.

Context

Inspiration

The phrases, and the allegations stated as allegations.

Universities, colleges, and schools

Syllabus use

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.

Six-week laboratory map