LI program Examples - Steven-Hewitt/LI GitHub Wiki

This is more or less just a dumpster for the sample programs I wrote as I was defining the language.

http://codegolf.stackexchange.com/questions/84712/print-a-bunch-of-uninteresting-numbers

M+.d

cat

(implicit i returned)

hello world

"hello world

http://codegolf.stackexchange.com/questions/84673/is-it-a-sum-free-set

}+,[M

Growing Quine (outputs valid source code that grows every iteration)

qq

Infinite Loop

R

ASCII art reflection (http://codegolf.stackexchange.com/questions/85363/ascii-art-reflection)

f~S\n?_ai~.d

Input is a truthy-falsy value followed by a string:

  S	                 Split
   \n                on newline
     ?_ai            if(?) not the first p(a)rt of the (i)nput:
         ~ d           reverse the second part of the input (i implied)
          .          duplicate the second part of the input as two parameters (only one used for ~)
                     else:
          .           (the duplicated `di` is used for the else)
f~                   flatten the reverse (condense into single list)

Factorial without builtin

@*Ryii1

@       If input is not zero:
  Ryi    Rerun program with decremented input
 *   i   and multiply by input
      1 Else return 1

Alternate Factorial without builtin

?_i1*Ry

?_i       If input is zero:
   1      	Return 1
     Ry   Else rerun program with decremented input
    *      And multiply by implied input

Fibonacci Sequence

?<i21+PRyiRyy

Alternate Fibonacci Sequence(inefficient and longer)

@cE"?<i2i+RyiRyy"Ryil

Collatz Sequence

?yPiR?%i2/i2+1*3

Truth Machine (print 0 and terminate on "0" input, print 1 forever on "1" input)

@LP

Stock Time Machine http://codegolf.stackexchange.com/questions/85469/stock-time-machine

)-C

Juggler Sequence

?yPiRf^i+h%i2