507
\$\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\$

229 Answers 229

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\$

FurryScript

Factoid

FurryScript was made for random text generation. It has some unusual features, such as:

  • No negative integer literals
  • Subtraction, but no addition
  • The return value of a subroutine is "OK", "bad", or "very bad"

Test snippets here.

Length 1

1

An integer literal. This won't really output anything, because first you have to convert it to a string. This can be done by appending an empty string:

1 +<>

Length 2

SU

Subtraction. Pops two values y and x and pushes x subtracted from y. For example, this:

6 5 SU +<>

outputs this:

1
\$\endgroup\$
5
\$\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\$
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\$

Author's note: While more snippets have been prepared, I will honor the original restriction somewhat and wait for interest.

Zsh

Zsh may seem like a new language, given the (relatively) recent popularity of the "Oh My Zsh" framework, but it in fact dates back to 1990, just one year after Bash released. Zsh's syntax is inspired by the bourne shell and ksh.

Many people are familiar with Bash scripting, but don't understand how Zsh differs. Zsh brings a surprising amount of powerful constructs. I'll be highlighting these differences here.

Length 1 Snippet

:

This is equivalent to the command true. It returns zero (truthy in shell scripts). Uses for this include short bodyless for loops: for ((x;y;z)):

Length 2 Snippet

$a

Parameter expansion. If a is set to some value, substitute that value.

Unlike in Bash and POSIX shells, if $a is an array, this will expand to all non-empty elements (or, in the language of shells, "words") of $a.

Length 3 Snippet

$=s

This is equivalent to the expansion ${=s}, which induces word splitting. For parameter expansion forms that involve a prefix (except for flags, see below) or modifiers (see below) the surrounding braces can be removed if unambiguous.

Unlike in Bash and POSIX shells, word splitting is not done on parameters by default. To split on $IFS, this construct is needed, or the option shwordsplit needs to be set.

Length 4 Snippet

*(.)

When expanding globs, Zsh supports glob qualifiers specified in parentheses after the glob. Appending (.) as above will cause this glob to expand to all regular files in the directory. There are dozens of globbing qualifiers, here are just a few:

  • /: Directories
  • F: Non-empty directories
  • @: Symlinks
  • U: Files owned by the effective UID
  • Yn: When n is a number, expand to the first n matches.

Length 5 Snippet

${~x}

This will expand x as a glob. This is useful to match filenames, match case expressions, and in [[ tests.

Length 6 Snippet

${s:l}

Zsh supports various modifiers to parameter expansion. The l modifier will lowercase all words of s. The equivalent construct in bash is "${s,,}" (or if s is an array: "${s[@],,}".

Other useful modifiers include:

  • a: Turns paths into absolute paths
  • A: Turns paths into absolute paths with symlinks resolved
  • s/foo/bar: Does replacement on each element. Use gs/foo/bar for global replacement.
  • &: Repeat the previous substitution.

Length 7 Snippet

${(i)@}

Zsh also supports roughly 30 parameter expansion flags. The i flag will sort the parameters case-insensitively.

  • k: Substitute the array keys instead of values
  • P: Induce indirect parameter expansion: if a='b' and b='c', then ${(P)a} expands to 'c'
  • q: Quote characters special to the shell with backslashes or $'\NNN'. q- and q+ will use different methods for quoting.
  • u: Remove duplicate words in the expansion.
  • z: Split into words according to shell parsing grammar: if c='"a b" c', then ${(z)c} will split into "a b" c.

Length 8 Snippet

xy${^a}z

With this expression, if a is some array (e.g.: a=(hello world)), a is converted to a brace expansion (e.g.: xyhelloz xyworldz

Length 9 Snippet

<<<${str}

Like in bash, this is a here-string. Unlike in bash, if no command is provided, the string is printed to stdout. This can often be used as a replacement for echo, except that the expansion of ${str} occurs in a subshell.

Length 10 Snippet

$a[(r)a?*]

Array subscripts also have flags! r is "reverse subscripting": This will give the first word in a whose value matches a?*. (Likewise, R gives the last match.)

Other flags include i and I which return the indices or keys of the match, k and K which match the keys, or w or f which split scalar a on words or lines, respectively.

Length 11 Snippet

b=(${@:*a})

This is another form of parameter expansion, it will expand to all words of "$@" that exist in the array a. Similarly, ${@:|a} will expand to the words of $@ which do not exist in a.

Length 12 Snippet

${${(f)s}:h}

One of the most powerful features of Zsh is that parameter expansions can be indefinitely nested. So this will take s, split it on newlines, and then strip each line's the last path component. (/usr/bin/zsh/usr/bin)

\$\endgroup\$
3
\$\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\$
3
\$\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\$

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\$

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\$

Keg

Factoid

Keg is a stack-based golfing language, created by PPCG user Jono 2906, 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\$
1
\$\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
1
\$\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\$ – Qwerp-Derp Jan 26 '17 at 4:02
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\$
0
\$\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\$

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.