esolang

Kitanai

Kitanai is Japanese for dirty, and the specification says the name is about its syntax.

2016 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, world!

The idea

Kitanai is from 2016, and its first interpreter was written in C++. A function name takes as many terms after it as it has arguments, with or without brackets, so print "hi", print("hi") and print"hi" are the same program. Nothing separates one statement from the next.

Read the story

Memory is a set of named stacks of cells. $ picks a stack or a cell, @ reads the picked cell and [...] writes it. There are no loops; a program marks flags with #, counted from 1, and jumps to them by number.

The machine

CharDoes
( )Run the terms inside; the value is the last one given
[ ]Store the value inside in the picked cell
$"name" $3Pick a stack; pick a cell in it
@The value in the picked cell
< >Pick the cell before or after
: ; ^The stack's name, the cell's number, the stack's size
# +A flag; the number of flags
&n *nJump to flag n, keeping the way back or not
&~Go back to the last &
?(test)(then)(else)Run then unless the test gives 0
!...!Code that never runs
%End the program

The built in functions are add sub mul div, the tests eq neq gt ge lt le, print println printerr input, string int, random time, split substr, bsfe bsfd for base64 and func, which makes a new function. add joins strings, and gt compares strings by length. print adds no line break and println does. Numbers are 32-bit whole numbers. random gives 0 or 1 and time gives 0, so a run always prints the same.

Example

Two of the six Hello Worlds.

Two of the six Hello Worlds. The second stores the text in the first cell and prints @.

Expected: Hello, world!

A cat. input shows its prompt, empty in this program, and reads a line.

Expected: cat

Fibonacci keeps n and two terms in cells 0, 1 and 2. Flag 1 starts the loop, and &1 jumps back while n is not yet 1. On 10 it prints the prompt and 55.

Expected: Fib : 55

A function definition, called once. A function finds its arguments in the stack args.

Expected: 7

The 99 bottles of beer program and the two Deadfish interpreters also work. Since print adds no line break, the verses of the first come out on one line.

Further

Also in Hostile

Write your own in Run Convert a program from Kitanai

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: kitanai.

Command line

shib run kitanai -e 'print(input(""))' --input 'cat'
shib manual kitanai

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/kitanai.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org