Source Link

Underload

Underload is a stack-based tarpit esolang, which can be a good choice for some problems (especially s) and a horrible choice for most of the others (but even horrible choices can be fun to golf in!). If you're planning to use it at CGCC, here's what you need to know:

The basics

CGCC questions normally require you to submit either a full program or a function.

A full program in Underload is just a string of code that runs, starting from an empty stack; it has no way to take input. As a consequence, this method of writing a submission is only really usable for questions that don't require your program to take input. It tends to be shortest when you can use it, though, because there's absolutely no boilerplate. Here's a Hello, World! full program:

(Hello, World)S

The rest of the time, your submission will have to be a function. A function can take I/O via any of the legal I/O methods. In the case of Underload, therefore, you need to take input from the stack; and can produce output either by pushing it onto the stack, or by outputting it with the S command. (You need to choose one or the other of these mechanisms to be your program's "official" output mechanism the other will be ignored.)

Additionally, under CGCC definitions, a function has to be reusable, i.e. it has to be possible to call it multiple times. As such, you aren't allowed to submit just the function body; you have to enclose the function in parentheses (so that it can be called multiple times by copying the function before calling it), and remember to include them in your byte count. Here's a Hello, World! function:

((Hello, World!))

To test your functions on Try It Online!, write them in the "code" box, and put the arguments in the "footer" box, in the form (arg1)~(arg2)~^, i.e. you swap the arguments below the function and then call the function. If the function produces output on its stack, you'll need to add an S to the footer to print it.

Numeric I/O

The normal definition of numbers in Underload is "Church numerals", which implement nonnegative integers like this:

0  !()
1
2  :*
3  ::**
4  :::***
5  ::::****

and so on. (Equivalent strings, like :*:* for 4, are also acceptable. 1 is an empty string.) These are basically programs that transform functions into looped/repeatedly applied versions of those functions, e.g. the number 4 is represented as any string which, if interpreted as a function body, will map a function λx.f(x) into a function λx.f(f(f(f(x)))) (or in Underload terms, replaces a string with four copies of itself). Programs in Underload that deal with numbers typically use this interpretation for numbers in the input and output.

Truthy/falsey

There are no generally-recognised ways to represent true and false in Underload, with the exact format depending on the program.

If a question does require you to use a language's specific true and false values (or specific truthy and falsey values), you should use ^ for true and ! for false, as these are the values you would need to use in the equivalent of an if statement. However, there's no reason to confine yourself to these representations for use internally within your program; use whatever representations are best for the challenge.

Lists

There isn't currently a consensus about how to represent lists in Underload, so do whatever makes the most sense for your program. (A string can be represented either directly, or as a list of character codes; the latter form will be required if you want to treat the string as anything other than an indivisible unit.)

Post Made Community Wiki by ais523 - high effort answers