526
\$\begingroup\$

Notes

  • This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional questions.

  • This is no longer a , nor are snippet lengths limited by the vote tally. If you know this thread from before, please make sure you familiarize yourself with the changes.

This thread is dedicated to showing off interesting, useful, obscure, and/or unique features your favorite programming languages have to offer. This is neither a challenge nor a competition, but a collaboration effort to showcase as many programming languages as possible as well as possible.

How this works

  • All answers should include the name of the programming language at the top of the post, prefixed by a #.

  • Answers may contain one (and only one) factoid, i.e., a couple of sentences without code that describe the language.

  • Aside from the factoid, answers should consist of snippets of code, which can (but don't have to be) programs or functions.

  • The snippets do not need to be related. In fact, snippets that are too related may be redundant.

  • Since this is not a contest, all programming languages are welcome, whenever they were created.

  • Answers that contain more than a handful of code snippets should use a Stack Snippet to collapse everything except the factoid and one of the snippets.

  • Whenever possible, there should be only one answer per programming language. This is a community wiki, so feel free to add snippets to any answer, even if you haven't created it yourself. There is a Stack Snippet for compressing posts, which should mitigate the effect of the 30,000 character limit.

Answers that predate these guidelines should be edited. Please help updating them as needed.

Current answers, sorted alphabetically by language name

$.ajax({type:"GET",url:"https://api.stackexchange.com/2.2/questions/44680/answers?site=codegolf&filter=withbody",success:function(data){for(var i=0;i<data.items.length;i++){var temp=document.createElement('p');temp.innerHTML = data.items[i].body.split("\n")[0];$('#list').append('<li><a href="/a/' + data.items[i].answer_id + '">' + temp.innerText || temp.textContent + '</a>');}}})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><base href="http://codegolf.stackexchange.com"><ul id="list"></ul>

\$\endgroup\$

235 Answers 235

1
4 5 6 7
8
5
\$\begingroup\$

Straw

Straw is a 1D stack-based language I created.
It mainly operate on strings.
You can try it online here.

Length 1

<

Take one line of input and exit.

Length 2

->

- take an item from the secondary stack, and > print it.
Straw have 2 stacks: The first is initialized with an empty string, and the second with Hello, World!.
So this code prints Hello, World!.

Length 3

9#>

Any character which is not a command is pushed on the stack, and # convert a decimal number to unary. It's needed to make any operations on numbers, because Straw don't have numbers, it only operate on strings. So this example prints 000000000.

Length 4

<<+>

Take two lines of input, concatenate (+) and print.

\$\endgroup\$
5
\$\begingroup\$

Arithmescript

Making an entry for Arithmescript here.

Codes

Length 1 snippet

i

Prints the value of i in the console.

Factoids

  • I am the creator of Arithmescript.
  • Arithmescript extends JavaScript.
  • It is sort of discontinued.

Demos

You can try out code in the latest version of Arithmescript at the official site.

\$\endgroup\$
  • 3
    \$\begingroup\$ Will you add snippets 2-4? \$\endgroup\$ – acrolith Sep 26 '16 at 0:05
5
\$\begingroup\$

D2

Factoid

D2 is a Brainfuck-like turing tarpit with a 2D memory model

Length 1

.

This prints 0. Why?

. is, like in Brainfuck, the print command. But since cells are limited to 36 values, D2 use a shift-state system to print most ASCII characters. In shift state 0, the alphabet is 0123456789abcdefghijklmnopqrstuvwxyz, and since the cell is initialized to 0, this print 0.

Length 2

;.

Now this print !.

The ; instruction increment the shift state. In shift state 1, the alphabet is !@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ, so this print ! because the current cell is 0.

Length 3

>}+

Explanation:

>   Turn the cursor 90° to the right
 }  Advance in the tape
  + Increment the pointed cell

So the memory after this is:

0
1

This demonstrate D2's 2D tape

Length 4

+$}^

This set the first cell of the tape to 1, put the value in the register, advance one cell and put the value of the register in the cell.

\$\endgroup\$
5
\$\begingroup\$

FEU

FEU (File Edition Utility) is a heavily regex-based language to edit files.

0 bytes

Cat program. Yep.

In FEU, the input is took implicitely at the start of the program anv every command works on the input. The input is printed at the end.

1 byte

/

/ execute the next block each time the input match a regex. Here, it will crash anyway because the block is not closed (end).

2 bytes

u/

The command u convert the input to unary, and the input is implicitely printed.

3 bytes

s/a

s is the substitution command, so this remove the first a in the input.

Empty fields are optional.

\$\endgroup\$
5
\$\begingroup\$

Octopen-Baru

Please note, this is a noncompeting answer because this langauge came out a few minutes ago.

Length 1 Code

Simple Quine, the Ruby output is puts('見').

Length 2 Code

倍五

Which returns 100 .chr (which is 'd').

Length 3

5那}

Which returns 5.times {}, so essentially do nothing five times!

Length 4

口同愛r

Which returns r=gets;puts r, so it takes whatever you input and gives it back!

Factoid!

This language has no purposeful use of the newline character. Also, all the commands come from Kanji/中文. Also still under active development.

\$\endgroup\$
  • 2
    \$\begingroup\$ Noncompeting answers are allowed, as this is a catalog. \$\endgroup\$ – Conor O'Brien Oct 24 '16 at 20:54
5
\$\begingroup\$

Attache

Factoid: This language originally started out as a joke, based on the "Mathematica has builtins for everything"; this can be seen by the residual Rot command, made for Rot13 and similar challenges.

Length 0 snippet

The empty program is valid in Attache. Try it online!

Length 1 snippet

V

Try it online! The V function was one of the first implemented. It represents a Vector of values, and used to be the only way to create array literals.

Length 2 snippet

`+

Try it online!

This is a quoted operator; it acts just as a function which performs addition. It can be assigned like so:

f := `+
Print[ f[1, 2] ]
?? prints 3

Length 3 snippet

1:9

Try it online! This is a demonstration fo the range operator in Attache. Attache's main focus resides in generation and selection, as is common with functional languages.

Length 4 snippet

Bond

Try it online! Bond is a function used to partially call functions. In this case, Bond[f, n] returns a function which takes arguments ...x and calls f[...x, n]. In the link, this is shown by example:

f := Bond[`/, 1]

This function returns a function which returns the reciprocal of the input. This is roughly equivalent to the lambda:

{ _ / 1 }

…but we'll get to that next.

Length 5 snippet

{_2-_}

Try it online! This is a lambda function, which can be called with any amount of arguments. These arguments are accessible using blanks, with _N referring to the Nth argument, starting at _1. _ is short from _1. So, this function can be written as:

{ _2 - _1 }

This is the 1st argument subtracted from the 2nd. In the example, we assign this function to f. Then, f[3, 6] is 6 - 3, which evaluates to 3.

Length 7 snippet

Print!7

Try it online! This shows the operator form of !, which takes a function on the left and an argument on the right. It's equivalent to function calling. This calls the inbuilt Print function with input 7, which outputs 7.

Length 8 snippet

~{-_'_2}

Try it online! This demonstrates a few more operators in Attache. First, ~, when used functionally, reverses the operands given to a function. So, for example, (~V)[1, 2, 3] would be called as V[3, 2, 1], which gives [3, 2, 1]. ~ has the effect of reversing the order in which abstracts are called. The above function could be rewritten as:

{-_2'_}

Now, the ' operator, when used on data, concatenates them. Since - is unary, it negates _2. This is equivalent to:

{ [ -_2, _1 ] }

Assign it as f, and f[1, 2] becomes [-2, 1].

Length 9 snippet

{Sum!_&_}

Try it online!

& when using data, a&b, creates an array of a copies of b. So, _&_ creates _ copies of _. 4&4 is, for example, [4, 4, 4, 4]. Then, Sum is called on that array. Thus, this squares a number.

\$\endgroup\$
4
\$\begingroup\$

Alphafuck

I'll use upvote * 2 because this language uses pairs

Length 6 snippet

noT INF

This is a infinite loop. Transpiles to -[].

Length 4 snippet

uMhM

Reads a letter and prints it. Transpiles to ,..
This does the same thing: uM hM.

Length 2 snippet

um

Now we're getting into things. This snippet transpiles into Branfuck +, which increments the current memory cell by one.

Length 1 snippet

1

Anything that isn't an letter is ignored. This snippet is basically a comment.

Factoid

Alphafuck is an esolang I made that transpiles to Brainfuck.

\$\endgroup\$
4
\$\begingroup\$

Bitwise Cyclic Tag

Factoid:

Bitwise Cyclic Tag is a programming language with only two commands, 0 and 1. It operates on an unbounded tape of bits and is somehow Turing-complete...? I don't yet understand this, but I'll be learning the language along with all of you. Bitwise Cyclic Tag is incredibly simple, even compared to brainfuck and other Turing tarpits, making it a very useful tool for proving other languages' Turing-completeness—if it can interpret BCT, it can do anything! In fact, our very own Ørjan Johansen did just this to prove /// Turing-complete in 2009, writing this interpreter.

Length 1 snippet

0

This here is half of the language. When a zero bit is encountered in the code, the first bit of the data tape is discarded (some implementations print it as well). That's it.

This program demonstrates an important feature of BCT: the code is not run just once, but over and over until the data tape is empty (hence, "cyclic"), at which point execution halts. Therefore, this 0.125-byte program can be considered a sort of cat program, as in any implementation that prints on discard, this will print the entire starting data tape in order and exit gracefully.

Length 1 snippet

1

This here is the other command in BCT. It's a touch more complicated. When a one bit is encountered in the code, if the first data bit is a one, the following bit in the code is appended to the data (on the end). If the first data bit is a zero, nothing happens. In either case, the bit in the code immediately following the 1 is skipped.

It is worth noting that I was not completely honest about repeated execution in the first snippet. The code is treated as a loop (think Haskell's repeat), so if this snippet is executed, the bit possibly written is the 1 itself. This snippet, then, will infinitely add ones to the end of the data if the tape starts with a 1 or do nothing forever otherwise.

\$\endgroup\$
4
\$\begingroup\$

International Phonetic Esoteric Language

Factoid

The International Phonetic Esoteric Language, or IPEL, is a stack-based esolang where the instruction set mostly consists of characters from the International Phonetic Alphabet, and some ASCII.

IPEL is an attempt to apply stuff I've learned from some CS courses since starting college, as well as to create a language for myself for code golf.

Length 1

1

IPEL has 3 types: numbers, strings, and lists. Numbers from 0-9 can be pushed in by using the digit.

Length 2

io

A simple cat program. i takes a string from STDIN, then outputs it with o.

Length 3

"a"

Pushes the string a.

Length 4

1esø

This code increments the loop index by 1. In IPEL, loops are not handled by the interpreter; the programmer has to manually set the loop index. Loops also only check for when \$index \lt end\$, where when true, jumps back to the start of the loop.

Length 5

<f>/\

An empty function definition.

Length 6

{12.34}

This is how you push a float and any numbers larger than 9. Surround it in curly brackets.

Length 7

|a|ɔ|a|

Labels also exist in IPEL. When execution hits ɔ, it will jump to the label specified right after the ɔ. This is also the shortest infinite loop you can do in IPEL.

Length 8

"C"ʁ2zχo

This is my answer to the "A Without A" challenge. It pushes C, converts it to a number, subtracts 2, converts it back to a string, and prints.

Length 9

{zzzzzzz}

IPEL since v1.4.0 includes the ability to push base 36 numbers. zzzzzzz is equivalent to 78364164095 in base 36.

Length 17

<f>/1ue2sø\<f>2u3u

This is the shortest program that demonstrates changing the return pointer of a function call. Without e2sø, this would print 123. With it would print 13 instead, completely skipping the 2 instructions 2u. I'm not sure if there's any practical use for this, but it's a thing you can do.

\$\endgroup\$
4
\$\begingroup\$

Arn

Arn is a golfing language I designed recently. It's a functional paradigm with variable-based storage, and has a few cool features I enjoy. The full syntax can be found by clicking the name at the top of this post. An online interpreter can be found here for those interested.

Features

Type casting

Arn will automatically cast types based on the following:

  • Arrays casting to Strings or Ints will take the 0th element.
  • Strings or Ints casting to Arrays will split on every character OR every space if there are any.

Assumptions

The variable _ will be automatically assumed in any place where one a value is missing but required.

Similarly, any closing ), ], }, ", ', or ` can be ignored if it reaches the end of an expression or the program.

STDIN

STDIN will automatically be assigned to the variable _ at runtime. It will be a string if STDIN is one line, or an array split on newlines otherwise.

Functions

Since functions exist in this language, and that means a Standard Library can exist! You will see example functions for that later.

Packing

In order to help Arn compete with other, golfing languages, a packed form exists. This form is shorter, encoded based on a modified CP1252 found here. The average compression rate, as far as I've found, is ~17%.

I am very happy with the encoding, I spent hours and hours on it. It may change to become every more concise in the future (if possible, and if I can figure out how) but until then, this will be how it works.

The interpreter can run Carn (Compressed Arn) and regular Arn without any indication of which is passed.

Compressed Strings

Should be pretty self explanatory. They are based on a dictionary found here.

The code is F * 100 + S OR F * 100, depending on if 1 valid compressed character or 2 are passed. Compressed strings are denoted with either ' or `, where the former capitalized every word and the latter just the first. You can find a full description on the GitHub page, linked at the top of the post.

Showcase

From top to bottom.

1 byte

_

This is a very simple program, it will just return STDIN. Output is implicit in this language.

2 bytes

+4

This program will add 4 to STDIN and return it. The same as saying _ + 4

3 bytes

4,7

Above features the use of an infix; specifically, the , infix. This infix is the pair verb; it takes the left and right argument, turning them into an array.

5 bytes

.fact

This little snippet shows us two new features (three, really!): the . infix, the fact function, and implicit casting. Since no value is passed to the . fix, it assumes _ on the left. This is then passed to the factorial function. The factorial function uses the 1-range fix, which takes an integer, and so _ is automatically casted to an integer.

7 bytes

+{+1}\~

This showcases the extremely useful \ prefix. This prefix operates as both a fold and map fix; it will map using the block preceding it (if provided) and then fold with the fixes preceding that. This snippet also shows the 1-range fix, ~, in action.

Essentially, this program takes a number on STDIN. It creates a range, from [1, n] (where n is the input). Then it maps over this range, incrementing each entry by one. Finally, it adds all of the entries together.

\$\endgroup\$
3
\$\begingroup\$

Keg

Factoid

Keg is a stack-based golfing language, created by PPCG user Lyxal, that focuses on simplicity and readability. It is fairly unique compared to most other golfing-based languages, since it has few instructions, and alpha-numeric characters are automatically pushed to the stack. It also has implicit input and output.

Length One

"

An example of the stack controls in Keg. This rolls the stack, which puts the top of the stack to the bottom. It is the opposite of ', which rolls the stack in the opposite direction, putting the bottom of the stack at the top.

Length Two

ab

Since these are alpha-numeric characters, they get auto-pushed to the stack as their respective ASCII values, which in this case are 97 and 98.

Length Two (bytes)

ߞ

Since this is not an instruction, this will be pushed onto the stack automatically. Keg allows Unicode characters to be pushed onto the stack, so this pushes 2014.

Length Three

83*

Any numbers get auto-pushed to the stack. In this case, it pushes 8, then pushes 3, and then multiplies them, giving 24.

Length Four

¿:+.

This shows how duplicating items and integer printing works by using nice input (evaluation of input) to double the given number.

Length Five

[a|b]

An example of an if statement in Keg. When an if statement is run, the top item of the stack is popped. If it is non-zero, the left code is run, whilst if it is zero, the right on the right is run. Note that the right side is optional

Length Six

(56*|1

An example of a for loop in Keg. The number on the left side is how many times it'll run, whilst the code on the right is what's run. In this case, it pushes 1 to the stack 30 times. If the left side isn't specified, it will automatically be the length of the stack. Also, all ending brackets get automatically completed at the end of the program, making this valid.

Length Seven

{!4>|.}

An example of a while loop in Keg. The code on the left is the condition, and the code on the right is what's run. In this case, while the length of the stack is greater than 4, it outputs the top element of the stack as an integer.

Length Eight

\ 
& &:.& 

This demonstrates a unique features of escaping characters and accumulator usage. The \ instruction escapes the newline, which has an ASCII value of 10, then the accumulator is set to 10. After that, the accumulator value will be accessed and printed, resulting in the program printing 10.

Length Nine

`Snippet`

This demonstrates the usage of strings in Keg. It pushes the string "snippet" and prints it.

Length Eleven

^!~$%(_|")_

This showcases most of the commands in one concise program. This removes exactly 1 character from 1 line of input randomly.

Length Twelve

@d1|:+ƒ¿@dƒ.

This defines a function called d and assigns the code :+ to it (doubling the input passed to it). Nice input is then taken (¿) and d is called on the input.

Keg Related Links

Esolangs Page

Official Github

Try it Online!

Keg Chatroom

\$\endgroup\$
3
\$\begingroup\$

Integral

Integral is a stack-based golfing language I recently made. It uses code page 437.

An interpreter.

1 byte

V 

Integral has many built-in functions. V reverses the top of the stack. Integral pushes all input to the stack and implicitly outputs the stack seperated by newlines.

12 bytes

÷▓ll▄å▒▌«s»÷

You can compress strings in Integral. This ouputs hello there person. Compressed strings are started and ended by ÷.

37 bytes

♂⌡ ⌡♦⌡_⌡g►⌡/⌡•⌡ ⌡g►⌡\⌡►•⌡|⌡♦⌡ ⌡g►⌡|⌡►

This is an example program that takes an integer as input, and returns an ASCII-art rainbow with width n.

I do not think Integral is Turing-Complete yet.

\$\endgroup\$
  • \$\begingroup\$ You probably want to update the 12 byter to ÷▌lloª• pô┼÷ (12 bytes) \$\endgroup\$ – user96495 Aug 7 '20 at 1:25
  • \$\begingroup\$ @petStorm The interpreter needs to be fixed first. \$\endgroup\$ – nph Aug 7 '20 at 11:39
  • 2
    \$\begingroup\$ Interpreter fixed. \$\endgroup\$ – user96495 Aug 7 '20 at 12:36
3
\$\begingroup\$

dotcomma

Dotcomma is a simple esolang I made, which uses only 4 instructions and is not Turing complete is now Turing complete, due to the addition of a queue for storage.

Factoid:

With only the instructions [.,], the . and , operators are heavily overloaded. For example, , can take input and output, manage the queue, test the number of times a code block was evaluated, and conditionally evaluate a code block. Which of these occur is decided by what characters precede and follow an operator.

Length 2 snippet:

All dotcomma programs are wrapped in code blocks ([]), so a length 1 snippet is impossible.

[]

This program does nothing.

Length 3 snippet:

[.]

This program sets its return value to 1. All operators and blocks have a return value, which can be used by other operators and blocks to nest expressions, create loops, or manage the programs's structure. If the . operator is preceded by [, it's return value is 1. If followed by a ], it uses its return value as the block's return value.

Length 3 snippet:

[,]

This program would previously take a value from input, and output it. The return value of the , operator would have been taken from input when preceded by [, and outputted if followed by ].

In "modern" dotcomma, this will take a value from the queue, and place it at the end of the queue. For example, given the input 6 7 8 (input is placed on the queue by default), this program would output 7 8 6 (final value of the queue is used as output by default).

Like the . operator, , will use its return value as a block's return value if followed by ].

Length 4 snippet:

[.,]

This program will output 1. As with the second snippet, the .'s return value is set to 1. However, because the , operator is preceded by an operator, it will use that operator's return value instead of taking a value from the queue.

Length 5 snippet:

[[,]]

This program will take a value from the queue, and place it back on the queue. However, it will have a return value of 0. This is because the , is wrapped in a nested block, and blocks default to a return value of 0 if an operator does not explicitly define one.

Length 6 snippet:

[[,].]

This program does the exact same thing as [,]. The . operator, if preceded by ], will set its return value to the sum of the return values of all previous un-separated blocks, which is only one in this case.

Length 9 snippet:

[[].[],.]

This will return the -1. The first empty block's return value will be read by ., which returns 0. As a result, the next block will be skipped (a loop that runs 0 times). Because the block preceding the , was never run, its return value will be -1.

Length 11 snippet:

[[,.][,.].]

This program uses the . operator's addition capabilities to take the sum of two inputs and use it as the program's exit code. Adding a . to the end of the , operators will prevent them from outputting, as they are no longer followed by ].

\$\endgroup\$
  • \$\begingroup\$ I already made a few answers using dotcomma, and for me it's a really interesting language. However, I'd like to suggest some improvements. I think the language would be more fun if you'd allow negative values on the queue. Of course that change would need a different option to determine if the queue is empty. My idea is to use .. and ,,, since those combinations aren't particularly useful in the current implementation. You could for example use ,, to return the length of the queue and .. to return the negative of the previous value, and then return 0 if you read from an empty queue. \$\endgroup\$ – Dorian Oct 5 '20 at 7:21
2
\$\begingroup\$

Logy

Logy is a logic, imperative and functional programming language.

0 bytes

A program without the main rule do nothing.

1 byte

#

Start a line comment

2 bytes

->

The rule definition operator

\$\endgroup\$
2
\$\begingroup\$

SQF

Factoid:

SQF (Status Quo Function) is the scripting language for the Real Virtuality engines (O:FP, ArmA, ArmA 2, ArmA 3). The games written for the engine are functionally just mods made in SQF.

Length 0 Snippet:

This is technically valid SQF, and does nothing unless it is treated as code, in which case it is a no-op.

Length 1 Snippet:

+

+ does the usual things in SQF:

  • Concatenation of arrays
  • Concatenation of strings
  • Addition of numbers

And something really cool as well:

  • Deep-copying of arrays (as a unary prefix)

Length 2 Snippet:

_x

_x is a magic variable which is used in these cases:

  • The current element in the optional predicate block argument of count (an array function)
  • The current element in the main block of a forEach block

Length 3 Snippet:

a-b

This subtracts b from a, if the operation is applicable to the types of a and b.
Like quite a few things in SQF, it does something particularly neat with arrays:

  • When a and b are arrays, the result of a-b is the set exclusion of b from a
\$\endgroup\$
2
\$\begingroup\$

Pushy

Info:

Pushy was never meant to be a language. It was originally just a postfix expression calculator, implemented with a stack. However, I (FlipTack) expanded it, adding several built-ins, loops, and (sort of) strings, it evolved into a language.

Snippets:

Note: in the showcase update, all answers are CW, so feel free to contribute to this post! Also, snippet length is no longer restricted by vote count.

Click on the header of any snippet to run it in the online interpreter!


Length 7 Snippet:

95&34_"

This program is the beginning in a chain of programs which output larger versions of themselves.

This program pushes 95, copies (&) it, then pushes 34. _ prints the stack's values, and " prints it again but as a string, resulting in:

95 95 34
__"

Which in turn outputs:

95 95 34
95 95 34
__"

5 or so iterations later, it looks like this:

95 95 34 95 95 34 95 95 34 95 95 34
95 95 34 95 95 34 95 95 34 95 95 34
__"__"__"__"
95 95 34 95 95 34 95 95 34 95 95 34
95 95 34 95 95 34 95 95 34 95 95 34
__"__"__"__"

...and it keeps growing forever. (If you iterate ~8 times, TIO begins to cut the output)


Length 3 Snippet:

:H"

This is in fact an adaption of my asterisk triangle answer. Given an integer, for example n = 5, it prints a "d-triangle" of this size:

d
dd
ddd
dddd
ddddd

This is a concise example of both loops and char-code conversion in Pushy:

:    \ Input times do (consuming input):
 H   \   Push 100 to the stack (character code for 'd')
  "  \   Print the whole stack, as a string.

As each iteration pushes a new 'd', this creates a triangle.

Notice there is no "end-loop" delimiter: this is normally signified with a ;. However, the interpreter automatically assumes these to be at the end of the program if omitted.


\$\endgroup\$
  • \$\begingroup\$ What's with the downvote? \$\endgroup\$ – FlipTack Nov 8 '17 at 18:23
2
\$\begingroup\$

tinylisp

Factoid:

tinylisp is a language made by @DLosc for an "interpret this language" challenge. Its intent is to demonstrate what a Lisp-like language can do using only very few builtins.

Here is an interpreter.

Snippet 1:

d

This single character is perhaps the most used builtin in tinylisp: the def builtin. It can be used to define variables and functions, and is basically required for every tinylisp program. Like any other lisp-like language, you define things like this:

(d x 10) // Creates a new variable x, and sets it to 10
(d succ  // Successor function, will be properly covered later
  (q (
    (x)
    (s 1 (s 0 x)))))

Snippet 2:

()

Everything in tinylisp (and basically most Lisp-like languages) are built off of parentheses. In tinylisp, these parentheses define an empty list - which is one of three data types in tinylisp:

  • Symbols
  • Numbers (which will be covered in the next snippet)
  • Lists

Snippet 3:

1.5

tinylisp has numbers, but surprisingly enough, this is not a number. Numbers (at least, numbers you can type down before compilation) in tinylisp only have the characters 0-9 in them, and anything else is a name, so these "numbers" aren't numbers in tinylisp:

-13    (contains -)
.335   (contains .)
17,232 (contains ,)

There's currently no way to define floats in tinylisp, however I'm working on implementing a fraction "class" thing in tinylisp. - Qwerp-Derp


Snippet 4:

disp

This is a four-character builtin in tinylisp, however most builtins are only one character (see snippet 1 for an example). This basically returns a value to STDOUT, with a trailing newline.


Snippet 5:

(v 1)

Yes, finally, a full statement that actually evaluates to something!

This evaluates the number 1, and therefore returns 1. That's simple enough - more complicated examples are to come.

Try it online! (from snippet 5 onwards, you should be able to test all of the programs).


Snippet 6:

(q(1))

This snippet quotes the list (1), and therefore evaluates to (1). I'm doing the best I can with 6 bytes...

q basically takes anything, and then returns the same thing, unevaluated. So for a program like this:

(q (s 1 2))

Instead of returning 3, it returns (s 1 2) instead.

Try it online!


Snippet 7:

(s 1 2)

s is the subtraction builtin; more specifically, it subtracts two integers. The above returns -1. Incidentally, s is the only way to get negative numbers in tinylisp (compare snippet 3).

Try it online!


Snippet 8:

(q(()1))

This is the simplest example of a lambda in tinylisp, and is essential to both evaluating other things and creating functions. The structure of lambdas is like so:

(q (  ;; Lambdas have to be quoted using "q", so not to get evaluated
  ()  ;; A list of arguments, in this example there are 0 args, so
      ;; this is an empty list
  1   ;; The "body" of the lambda: in this case, we're returning 1
      ;; for every input.
))

This statement is essentially similar to the Python lambda lambda:1 (which is also 8 bytes long, coincidentally). It can be used like so:

( (q(()1)) )  ;; evaluates to 1

Try it online!

\$\endgroup\$
  • \$\begingroup\$ You don't actually say how to define floats. What if I want to enter 1.5? \$\endgroup\$ – Pavel Jan 26 '17 at 4:01
  • \$\begingroup\$ @Pavel There's no way to define floats in tinylisp, unfortunately... :p \$\endgroup\$ – clismique Jan 26 '17 at 4:02
2
\$\begingroup\$

NO!

Factoid

The only valid characters in NO! are NOno!?. This language was created 2 hours ago and I'm currently writing this with my 12th cup of coffee in my hand. This language is close to the antithesis of code golf as demonstrated by this answer to the Hello, World! challenge.

Snippets

Hello, World!

NOOOOOOOOO?Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooo Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Nooooooooooooooooooooooooooooooooo
NOOOOOOOO?no

Add two numbers

NO?NOOOOOOOOOOO!NOOOOOOOOOOO
NOOOOOOOO?no

Prime Tester

NOOOOOOO?NOOOOOOOOOOO
NOOOOOOOO?no
\$\endgroup\$
2
\$\begingroup\$

CGL (CGL Golfing Language)

(or Code Golf Language, this was not intentional :)

Factoid

CGL uses the stack concept like a lot of other golfing languages, but unlike them it has an infinite number of stacks that it has. Most operators operate on the current stack except some that change the current stack or move things. Stacks have numerical indexes. 0 is the default stack. The -1th stack is where input is stored.

I am unsure how bytes are counted for some of this unicode, so feel free to correct me in comments.

1 byte

h

Outputs Hello, World!. Actually pushes Hello, World! to the current stack (default 0) and the first element in the current stack is outputted by default.

2 bytes

There are a lot of possible 2 byte programs, but I wanted to show a cool operator in this one: -. - decrements the current stack, in this case switching from 0 (default) to -1 (where input is stored). ² squares the current stack. The first item in the current stack is outputted by default, so this squares the input and returns it.

3 bytes (uses a combining character)

'҄҄낄䀀

This shows off the neat string compressing function. Normally, you wrap a string in "s and it is pushed to the current stack. 's enable you to use compressed strings. ҄낄䀀 is the compressed version of Hi! (note in this example, there is no compression savings, but with longer strings there often is. Also, you can use & to compress the current stack.) Quotes are auto-completed if you leave them off.

4 bytes

-#2➕

Adds 2 to the input. adds the second stack item to the first or 1 to the first if the second stack item is non-existent.

5 bytes

-#1+Ⓧ

The # pushes the following number to the stack. Note that technically numbers are wrapped in #s, but if you leave them off they will be added between the last digit and any non-number character. The (diffrent from +) adds the first 2 stack items and pushes that to the stack. outputs the last item from the stack and exits. This therefore adds 1 to the input.

\$\endgroup\$
2
\$\begingroup\$

Decimal

Decimal, also called 09D by some users, is an esoteric stack-based programming language I created that uses only the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and D.

Factoids

  • Decimal is stringly typed. The PUSH code for STRING is 3.
  • Decimal was on tio.run from day 1 of its release.
  • Decimal is not based on the top of the stack. It's based on a Default Stack Index (DSI). All functions that write to the stack set this index.
  • While very obfuscated, Decimal can be easily translated into pseudo-stack code.
  • All characters other than 0-9 and D are simply printed as they appear in the source code. This excludes whitespace.
  • Decimal uses Assembly-like comment syntax, e.g. ;COMMENT.

The Decimal GitHub repo is here.

Length 1 snippet

2 is the command for POP. Simple enough. POP pops the DSI from the stack.

2

Length 1 snippet

5 is the command for IF/ENDIF.

5

If not in an if-statement, 5 will check the DSI value. If truthy, the interpreter will continue reading as normal. If falsy, it will ignore all commands until 5, except JUMP. JUMP will exit any if-statement.

If currently in an if-statement, 5 acts as ENDIF.

Length 3 snippet

Command 3 is the command for I/O. The first argument specifies where to read from (0 for stack, 1 for user input). The second argument specifies where to put the read value (0 for stack, 1 for output).

All I/O commands are 3 characters long.

Length 3 snippet

Command 9 is the command for JUMP. JUMP commands must end in the character D. JUMP 0 exits the program.

91D

If jump #1 has not been declared, 91D will declare it. If jump #1 has been declared, 91D will jump to it.

Length 4 snippet

Command 4 is the command for MATH. See the MATH section in the Decimal README for more information on MATH arguments. Each MATH command must end in D.

412D

This compares STACK[DSI-1] and STACK[DSI] for equality, pops both, and pushes the result.

\$\endgroup\$
2
\$\begingroup\$

Triangularity

Factoid

Triangularity is a minimalistic esolang, which can (for now) only perform very basic arithmetic and string / list manipulation. As its name might suggest, every piece of code should be padded nicely with triangles of dots. Valid Triagularity programs must have the character count listed in OEIS A056220 (except for -1), otherwise you are probably doing something wrong.

Length 1

)

This just pushes a 0 onto the stack, and the top of the stack is implicitly outputted.

Length 7

.).
IEp

First off, ) pushes a 0 onto the stack, the argument to I, which retrieves the 0th line from STDIN. E evaluates it to an integer and finally p tests our integer for primality.

Length 17

..)..
.IE).
@IE+.

Adds any two valid inputs, either numbers or collections.

Length 31

...)...
..IE)..
.0>)@_.
^)IE/..

Computes the absolute value of a number, by multiplying by its sign, with a few tweaks.

Length 49

....)....
...2)1...
../D)IE..
.^is)@IE.
^i=......

Checks if the integer part of the square root of two numbers given as input is identical.

Length 71

..... .....
...."!"....
..."ld"+...
.." Wor"+..
."Hello,"+.
...........

Of course, we need a "Hello, World!" program! This can actually be golfed down to 49 bytes

.... ....
..."!"...
.."ld"+..
." Wor"+.
"Hello,"+

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Pain-Flak

Pain-flak is brain-flak's evil sibling, I would just read the docs here

6 Bytes:

))((}{

That pushes 1 to the stack (stack clean)

156 Bytes:

><))))))))))))()()()((}{(}{(}{)((((}{}{)((][][][][(][][(]][[)((]][][][][][[)(()‌​])][)][(][][}{([)()()()]][[))])()()([)])][][][([))))}{)((}{(((}{}{(((((}><{

The hello world program made by Dennis (run with -A)

\$\endgroup\$
2
\$\begingroup\$

평범한 한글(Unsuspected-Hangul)

Unsuspected-Hangul is functional esolang.

Factoid

Unsuspected-Hangul only uses 10 consonants of Korean character : ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅎ, and other consonants are replaced by them. Vowels and final consonants are dismissed. Non-hangul(alphabet, number, white spaces) are all same.

Rule of replacement

ㅊ -> ㅈ, ㅋ -> ㄱ, ㅌ -> ㄷ, ㅍ -> ㅂ
ㄲ -> ㄱ, ㄸ -> ㄷ, ㅃ -> ㅂ, ㅆ -> ㅅ, ㅉ -> ㅈ
ㄳ -> ㄱㅅ, ㄵ -> ㄴㅈ, ㄶ -> ㄴㅎ, ㄺ -> ㄹㄱ, ㄻ -> ㄹㅁ, ㄼ -> ㄹㅂ, ㄽ -> ㄹㅅ, ㄾ -> ㄹㄷ, ㄿ -> ㄹㅂ, ㅀ -> ㄹㅎ, ㅄ -> ㅂㅅ

You can try unsuspected-hangul here

Length 1

ㄱㄴㄷㄹㅁㅂㅅㅈ is number : From zero to seven.

Only initial consonant counts : so it is same as , So it returns 0.

강 means river.

Legnth 2

나무

Even-length number is negative, while odd-length number is positive. Every number is octal.

ㄴ is 1, and ㅁ is 7, and it is written backward, so ㄴㅁ is -71(octal), -33(decimal).

나무 means tree.

Length 3

코끼리

This is odd-length, so it is positive. It is equivalent of ㄱㄱㄹ, 300(octal), and 192(decimal).

코끼리 means elephant.

Length 4

집전화기

Now introducing : types. Unsuspected-hangul has 7 types : Number, Boolean, String, List, Closure, IO, Nil.

ㅈㅈ is built-in function that returns True. And ㅎㄱ calls function with 0 parameters. So ㅈㅈㅎㄱ returns True.

집전화기 means Home telephone.

Length 5

문자 한개

Non-hangul(like space) right before can be omitted. ㅁㅈ is built-in function that changes number to string (if given with parameter). If ㅁㅈ called with no parameter, it just returns empty string.

So ㅁㅈ ㅎㄱ returns ''

문자 한개 means One character.

Length 6

평범한 한글

Yes, It is name of the language. It is equivalent of ㅂㅂㅎ ㅎㄱ.

makes function. ㅂㅂ ㅎ( is ㅂㅂㅎ) is function that returns -45.

ㅎㄱ calls function with no parameters, so it returns -45.

평범한 한글 means Ordinary Korean character, or Unsuspected Hangul.

Length 7

또 또 신호등

ㄷ ㄷ ㅅㅎㄷ. is built-in function for power. ㅎㄷ calls function with two parameters. (Remember ㄷ means 2?)

So it calculates 2^2, and returns 4.

또 또 신호등 means Traffic light again again.

Length 8

나 과제 다했다

ㄴ ㄱㅈ ㄷㅎㄷ. is built-in function for addition. ㄱㅈ is -56, so it calculates 1 + (-56), and returns -55.

나 과제 다했다 means I'm done with my assignment.

From github readme.md file.

Length 9

그는 자는 척했다

ㄱㄴ ㅈㄴ ㅈㅎㄷ. is built-in function for comparison. If first parameter is smaller than second parameter, returns true. ㄱㄴ is -8, and ㅈㄴ is -15. So it returns False.

그는 자는 척했다 means He pretended to sleep.

\$\endgroup\$
1
\$\begingroup\$

MY

MY currently has no implemented codepage, so code will be listed in both bytes and the unimplemented codepage, one following the other. MY is stack based and "vector oriented" (like Jelly, some commands automatically "vecify" over their arguments). MY also has an "Object Subject Verb" visual order of commands.

1 byte

27
↵

This program outputs 0 with a trailing newline. MY does not have implicit input nor implicit output, if one pops from an empty stack, it pops 0.

2 bytes

1F 27
⍞↵

This program takes a line of raw input, then outputs it (with a trailing newline). MY can't do very much in 1 or 2 bytes due to lack of implicit IO.

3 bytes

1F 64 27
⍞h↵

Reads a line from STDIN, then converts it from hexadecimal (must be uppercase) to an integer. This beats Jelly.

4 bytes

01 02 81 26
12-←

This is where the quirk of MY comes in, for multiple argument commands, MY pops the amount of arguments needed, then applies them to a function in the order that they are popped. OSV, this resembles (hence, the Y standing for Yoda). Thus, the above code outputs 1 rather than -1 (without a trailing newline).

5 bytes

01 4D 02 80 26
1W2+←

This showcases MY's "vector orientation". This differs from APL and J, but is more like Jelly's concept of vectorizing ("vecifying" in MY). The program pushes 1 to the stack, wraps that in an array, pushes 2 to the stack, adds the top two elements, then displays with no newline (outputting [3] due to the "vecification" of commands).

\$\endgroup\$
1
\$\begingroup\$

W

Factoid

W is a simple stack-based golfing language that is surprisingly very concise. Its powerful iterator protocol and implicit input system is the cause for this.

Length 1

w

This is in fact a valid Truth-machine program (infinite 1 while 1). Let's explain it. The first step of the execution is to prepend all of the possible inputs to the stack:

aaw

Note that the input is used both as the condition and as the body of the while loop. Therefore this program decodes to the following pseudo code:

while the input:
    print the input

The print is implicit in every while iteration. So if the input is 1 (a truthy value), this prints the input 1 indefinitely.

You might want to ask, could this code snippet produce the right result for a 0 input? Yes; the while loop returns the condition onto the stack after the execution, therefore 0 is outputted onto the stack.

IMPORTANT NOTE. W's while loop is only for demonstration purposes. Never use this instruction, because W is designed to allow users to use for loops over while loops.

Length 2

+M

The W snippet that I am most proud of! It showcases more of W's powerful protocol.

So let us first try to make 'z' (the string) as an input. The program outputs:

aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz

Well, you might be confused by this odd output. Don't worry; I will explain it.

aaa+M

This transpiles to:

map(a,a+a)

Which means double every item in the string. If the string was 'ab' then the output would be 'aabb'.

So, why in the world would it return the doubled alphabet? Well, the Map instruction has an automatic range that allows users to iterate over a singleton. (Because it is pointless to do so)

In this context, this will return a range from lowercase a to z, hence the doubled alphabet.

\$\endgroup\$
1
4 5 6 7
8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.