esolang

CopyPasta Language

A program copies lines to a clipboard, edits it by character position, and pastes it once at the end.

Rerednaw, 2018 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

Rerednaw made CopyPasta Language in 2018, after the copypasta meme. The only memory is the clipboard and the only output is pasting it, which also ends the program. The first version, Ctrl+C, can copy, duplicate and paste. The Ctrl+V version adds deleting, shifting characters, comparing two characters and a goto, and with those it computes.

The machine

Every command is a line, and its argument is the line after it. Characters and lines count from 1.

CommandArgumentDoes
Copya line of textAdd the text to the clipboard
CopyFileTheFuckingCodeAdd the program's own source
DuplicatenThe clipboard becomes n + 1 copies of itself
Pasta!Print the clipboard and stop
CoolStoryBroa bDelete characters a to b
Creepya b nAdd n to the codes of characters a to b, modulo 256
IfAndOnlyIfAndOnlyIfAndOnlyIfa bRun the next command only if characters a and b are equal
BUTI'MNOTDONEYETnGo to line n

Example

The second is the cheating quine.
Expected: CopyFile TheFuckingCode Pasta!

The second is the cheating quine. It copies its own source.

The mini Fibonacci from the specification keeps the numbers as digits in the clipboard, ---- 0 1 1 0 0 0 0 0, and adds with Creepy, which moves a digit's character code up or down by one. Each round counts one number down to 0 while it counts the next one up, and then deletes two dashes. After two rounds the clipboard is 0 0 0 2 3 0 0 0, and CoolStoryBro cuts it down to the two new numbers.

Expected: 2 3

Patterns it teaches

  • String rewriting: all state is one string, edited by position.
  • Quine: a command that reads the source makes the quine trivial.

Further

Also in Jokes

Write your own in Run Convert a program from CopyPasta Language

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: copypasta-language.

Command line

shib run copypasta-language -e 'Copy
Hello, World!
Pasta!'
shib manual copypasta-language

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/copypasta-language.js

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

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