Introduction - Steven-Hewitt/LI GitHub Wiki

1. So, what is this "LI" thing?

LI is a (mostly) functional programming language based off of LISP, particularly built for code golfing. It's currently in extreme infancy, and the interpreter will probably migrate languages.

LI programs are understood by the interpreter as lambda expressions with one input of some form called i. (Additional inputs can be passed to LI programs by packaging the inputs into lists of input expressions.) Every function in LI has a fixed arity, which eliminates the need for explicitly-defined lists; this allows for some functions to change or extend lists at runtime, particularly the duplicate and triplicate operators (. and : respectively).

1.1 I'm interested! How do I start?

Great! Let's go through a couple of examples of LI programs and walk through what they do. The obvious place to start is with "Hello, World!", as that's the first program many programmers create as their first language.

1.1.1 Hello, World! (13 bytes)

"Hello, World!

That's it. To some who have studied other golfing languages (such as Pyth), this may look familiar. LI automatically fills in missing arguments for you with a default argument, and the function " must be ended with another ", so LI automatically fills that argument in. In addition, the result of the function is returned by the implied lambda surrounding an LI program, which prints such output to the standard output stream.

Now let's try out some math.

1.1.2 Adding!

+22

Just as in LISP, LI uses prefix notation for operators (which are, of course, more functions). Note that there's no separator between the two 2s: 2 (and all single-digit characters) are as much functions as everything else (returning their numeric value), and as such are single characters. If we want to add multi-digit numbers, we need to use the ' number literal builder:

1.1.3 Adding (numbers higher than 9!)

+2'10

or

+'10'2

or

+'10"10

Just like with our "Hello, World!, we don't need to close the number literal building function with another ' if it's the last argument. We need to close it in the second variation, though; we don't want to interpret it as 102. If multiple multi-digit numbers are next to each other, LI is smart enough to interpret a double quote as two single quotes, allowing the last variation to function as intended and output 20.

The functions -, m (since * is defined as a separate function), and / are defined in more or less the same way.

Once we have math, we can start to have user interaction.

1.1.4 Input

*i2

*2+3

Remember, all LI programs are lambda functions. As a function, it takes an input (which, by default, is called i) which can be accessed throughout the program. The first example, for example, doubles the input and returns the result.

So how is the second program interactable? In fact, how does it compile? LI is a prefix-notation language, so the program is equivalent to the infix version (2 * (3 + )). 3 +...? This is an example of another implicit default argument, which in this case is the input. In pre-processing, LI expands the second program to *2+3i, which is slightly clearer.

Now let's talk control flow.

Actually, since I don't have that written up yet I just have a bunch of sample programs. Sorry!