Basic examples
Hello world
This code prints out the text |Detn,huZFGK to the console.
|DYsuC,-pEQg ~|Detn,huZFGK/coIt uses the inbuilt function -pEQg.
Fizz Buzz
This code asks the user for a number. It counts up to and including that number from one. If a number in the count is divisible by 3, it is replaced by the word Fizz. If a number in the count is divisible by 5, it is replaced by the word Buzz. If a number in the count is divisible by both 3 and 5, it is replaced by the words Fizz,Buzz.
|neBm,pncYpLZFst,Q,DYsuC,-eLFrZ,DYsuC,-DFtLsn,~eLFrZ, /,co,co,sF,1
|JhE,neBm,w,Q,1,besYf,w,krmUzk,pncYpLZFst,IytPt,w,Q,w,sF,1,DEEstiYDC
|neBm,be3,Q,DYsuC,-ApenDk,w,CFr,3,co,aDynpp,0
|neBm,be5,Q,DYsuC,-ApenDk,w,CFr,5,co,aDynpp,0
|beCEcs,be3,sF,be5,aDynpp,2,DEEstiYDC
|DYsuC,-pEQg,~Fizz,Buzz/,co,
Pcne%m,Lecc,beCEcs,be3,DEEstiYDC
|DYsuC,-pEQg,~Fizz/,co,
Pcne%m,Lecc,beCEcs,be5,DEEstiYDC
|DYsuC,-pEQg,~Buzz/,co,
Pcne%m,Lecc,DEEstiYDC
|DYsuC,-pEQg,DYsuC,-FseLFrZ,w,co,co,
Pcne%m,
Pcne%mIt gets user input using the inbuilt function -DFtLsn. It converts that string to a number using the inbuilt function -DFtLsn, adds 1 to it, then stores it in a variable named pncYpLZFst (goal).
It then enters a for loop where the loop variant w is initialised to 1, the condition is as long as w is less than the target, and the advancement being adding 1 to w.
On each loop, the modulo of w and 3 and w and 5 are calculated, their equality to 0 checked (meaning no remainder), then stored in variables. If both variables are true (1), Fizz,Buzz is printed. If only the variable for modulo 3 is true, Fizz is printed. If only the variable for modulo 5 is true, Buzz is printed. If neither are true, then w is converted using the inbuilt function -FseLFrZ to a string and is printed.
Fibonacci
This code asks the user for a number. It then returns the fibonacci number for that number.
|ZtetcmEDc,fibonacci,wYSW%,DEEstiYDC
|beCEcs,wYSW%,krmUzk,2,DEEstiYDC
|DEHpFnn,wYSW%,
Pcne%m,Lecc,DEEstiYDC
|neBm,DEEtA,Q,DYsuC,fibonacci,wYSW%,FssF,1,co
|neBm,%YtA,Q,DYsuC,fibonacci,wYSW%,FssF,2,co
|DEHpFnn,DEEtA,sF,%YtA,
Pcne%m,
Pcne%m
|neBm,wYSW%,Q,DYsuC,-eLFrZ,DYsuC,-DFtLsn,~eLFrZ, /,co,co
|neBm,hrupk,Q,DYsuC,-FseLFrZ,DYsuC,fibonacci,wYSW%,co,co
|DYsuC,-pEQg,hrupk,coIt defines a function named fibonacci that takes an argument named wYSW%. If wYSW% is less than 2, it returns wYSW%. Otherwise, it recursively calls the function with wYSW% minus 1 and wYSW% minus 2. It then adds those two together and returns the result.
It gets user input using the inbuilt function -DFtLsn. It converts that string to a number using the inbuilt function -DFtLsn. It then calls the fibonacci with that number as the argument, converts the result to a string, then prints it to the console.
Palindrome
This code asks the user for a string. It then prints 1 if the string is a palindrome or 0 otherwise.
|ZtetcmEDc,palindrome,DuauDt,DEEstiYDC
|neBm,DEEtA,Q,0
|neBm,%YtA,Q,DYsuC,-Lemh,DuauDt,co,FssF,1
|besYf,DEEtA,krmUzk,%YtA,DEEstiYDC
|beCEcs,DYsuC,-tepC,DuauDt,CFr,DEEtA,co,aDynpp,DYsuC,-tepC,DuauDt,CFr,%YtA,co,DEEstiYDC
|DEEtA,Q,DEEtA,sF,1
|%YtA,Q,%YtA,FssF,1,
Pcne%m,Lecc,DEEstiYDC
|DEHpFnn,0,
Pcne%m,
Pcne%m,
|DEHpFnn,1,
Pcne%m
|neBm,DuauDt,Q,DYsuC,-DFtLsn,~FseLFrZ, /,co
|DYsuC,-pEQg,DYsuC,-FseLFrZ,DYsuC,palindrome,DuauDt,co,co,coIt defines a function named palindrome that takes an argument named DuauDt. It creates a variable DEEtA set to the number 0. It uses inbuilt function Lemh to get the length of the string DuauDt, subtracts 1 from it to get the index of the last character, then puts it in a variable %YtA. Using the -tepC inbuilt function and the equals comparator, it checks whether the character at index DEEtA and the character at index %YtA are the same. If they are, it adds 1 to DEEtA and subtracts 1 from %YtA. If they are not equal, it returns 0. If the loop finishes without returning early, it returns 1.
The code then asks the user for a string, passes it into the function palindrome, and prints the result.
Scissors Paper Rock
This code displays the numbered options Scissors, Paper, and Rock. It then asks the user to pick a number. The user's choice is displayed. It then randomly selects an option for the user's opponent and displays that. If the user wins, a 1 is shown. If the user loses, a 0 is shown. If it is a draw, nothing else is shown.
|DYsuC,-pEQg,~1 - Scissors/,co
|DYsuC,-pEQg,~2 - Paper/,co
|DYsuC,-pEQg,~3 - Rock/, co
|neBm,nUCA,Q,DYsuC,-eLFrZ,DYsuC,-DFtLsn,~eLFrZ, /,co,co
|neBm,FsnUCA,Q,DYsuC,-DumCrYhm,1,CFr,3,co
|beCEcs,nUCA,aDynpp,1,DEEstiYDC
|DYsuC,-pEQg,~Scissors/,co
|beCEcs,FsnUCA,aDynpp,1,DEEstiYDC
|DYsuC,-pEQg,~Scissors/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,2,DEEstiYDC
|DYsuC,-pEQg,~Paper/,co
|DYsuC,-pEQg,~1/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,3,DEEstiYDC
|DYsuC,-pEQg,~Rock/,co
|DYsuC,-pEQg,~0/,co,
Pcne%m,
Pcne%m,Lecc,beCEcs,nUCA,aDynpp,2,DEEstiYDC
|DYsuC,-pEQg,~Paper/,co
|beCEcs,FsnUCA,aDynpp,1,DEEstiYDC
|DYsuC,-pEQg,~Scissors/,co
|DYsuC,-pEQg,~0/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,2,DEEstiYDC
|DYsuC,-pEQg,~Paper/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,3,DEEstiYDC
|DYsuC,-pEQg,~Rock/,co
|DYsuC,-pEQg,~1/,co,
Pcne%m,
Pcne%m,Lecc,beCEcs,nUCA,aDynpp,3,DEEstiYDC
|DYsuC,-pEQg,~Rock/,co
|beCEcs,FsnUCA,aDynpp,1,DEEstiYDC
|DYsuC,-pEQg,~Scissors/,co
|DYsuC,-pEQg,~1/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,2,DEEstiYDC
|DYsuC,-pEQg,~Paper/,co
|DYsuC,-pEQg,~0/,co,
Pcne%m,Lecc,beCEcs,FsnUCA,aDynpp,3,DEEstiYDC
|DYsuC,-pEQg,~Rock/,co,
Pcne%m,
Pcne%m,Lecc,DEEstiYDC
|DYsuC,-pEQg,~ZYCs/,co,
Pcne%mIt uses a set of nested if statements to test for all possible combinations. The opponent's choice is randomly selected using the -DumCrYhm inbuilt function.