Sakana

From Esolang
Jump to navigation Jump to search

Sakana (魚) means 'fish' in Japanese. It is an esoteric programming language created by User:TheCanon2. Sakana is chiefly a derivative of Deadfish, but it also takes ideas from brainfuck and ΙΧΘΥΣ.

Code written in Sakana can be represented as either ASCII (アスキー魚, ASCII-Sakana) or Japanese text (和魚, Wa-Sakana). This article will use the Wa-Sakana variant.

Commands

Like Deadfish, and like its predecessor Shinda Sakana, Sakana has a single accumulator, x. Unlike Deadfish and Shinda Sakana, Sakana has commands for handling input. Sakana has fourteen commands.

Normal commands

ASCII Japanese Term Action
i 増加 (zouka) Increment x
d 減少 (genshou) Decrement x
w 空にする (karanisuru) Set x to 0
z 質問 (shitsumon) Skip next instruction if x == 0
s 二乗 (nijou) Square x
o 出力 (shutsuryoku) Output x as number
c 書く (kaku) Output x as Unicode
r 読む (yomu) Comma in brainfuck, but UTF-16
h 停止 (teishi) Halts the program

Special commands

ASCII Japanese Term Action
p 魚 (sakana) Comma in brainfuck, but replace itself with the character and interpret as Sakana
(Other characters) (Symbol) If first of (Symbol), start definition of function (Symbol), else execute function (Symbol)
(Kana) Symbols.
m 作る (tsukuru) End definition of function (Symbol)
f 繰り返す (kurikaesu) Within definition of function (Symbol), repeat function (Symbol)
b 壊す (kowasu) Within definition of function (Symbol), stop execution of function (Symbol)
# Start/end comment

When creating a definition, (Symbol) and behave as open and close parentheses. A function can only be defined if it has its own that is not shared with a larger function. Function definitions do not execute, definitions can only be called from elsewhere in the program. Undefined functions are ignored by the Sakana langauge.

can be used as the beginning of a definition if it is not a known function or command and is paired with a (note that this is case specific to the user input).

The function works on the same internal counter as i.e. the hypothetical code 魚読魚 means that the 1st and 3rd characters of a string are interpreted as program data but the 2nd character is interpreted as text.

Like in Deadfish, x is set to 0 if x == -1 or x == 256.

Examples

Kon'nichiwa sekai

い増増増増増増増増増増作で減減減減減減減減減減作ひいいいいいいいいいい作
増増増乗増乗い増乗いいいいい書いいいいいい増増増増書でででで書で書い増増増増書
空い増乗いい乗ひい減書空い増増増乗増増増増乗ひ減

Outputs the text, "こんにちは世界". The い, で, and ひ functions are used to save space.

Deadfish interpreter

i増作d減作s乗作o出作コ魚繰作コ

Standard 'idso' variant. Defines the functions i, d, s, o, and the main loop コ. Then it executes コ and uses the function to grab program data from the user.

XKCD variant:

x増作k乗作c出作d減作コ魚繰作コ

Truth machine

0出停作1出繰作魚

Cat

ね読書問繰停作ね

XKCD Random Number

ラ空増増乗#Chosen by fair dice roll.##guarenteed to be random.#作ラ出

Function ラ sets x to 4.

or as a program:

増増乗出

Parity calculator

ツ減減作
グ空増増増乗乗減減書空増増増乗増乗書書停作
キ空増増乗増増増増乗増増増増増書空増増増乗増増乗減減減書空増増増乗増乗増書増増増増増増増増増書停作
エ減問壊キ作オ問壊グ作サオエツ繰作読サ

Outputs the parity of a Unicode value. Functions グ and キ print 'Even' and 'Odd' respectively. Function サ is the main loop and is halted by functions エ and オ when the parity is found.

Small interpreter

お問壊魚作+増#Adds 6 to check if x is equal to 250#増増増増増増お減減減減減減作.書作チ魚作チ

This program interprets the minimalist language Small.

The お command takes advantage of the fact that position does matter, it will not execute + or . because they were defined after お was defined.

Print all* of Unicode

は減減減減減減減減作ユ書増問繰#Print 257:#増増乗乗増乗はははは繰作ユ

This program prints every Unicode character in order, except for Ā at U+0100.

Print all* natural numbers

は減減減減減減減減作イ出増問繰#Print 257:#増増乗乗増乗はははは繰作イ

Similar to the Print All* Of Unicode program, this program prints all natural numbers in order, except for 256.