RFOL

From Esolang
Jump to: navigation, search

RFOL or Repeating FOur Language was designed by Tslil Clingman in early June of 2008 for the purposes of beginning to program in Python. The language was thus intended to be as minimal as possible to ease the learning curve for the author.

Overview

The language's simplicity extends to the availability of only 4 possible instructions and 26 possible variables. The possible variables encompass the 26 letters of the alphabet (all lower-case) and thus anything not a variable is a no-op, the most frequently used of which would be the "space"

The four commands are:

1. Inc
2. Dec
3. Begin if >0 loop
4. End if >0 loop


Explanation (if ever were one needed)

The method of programming is simple, if the command currently pointed to by the IP (defaulted at 0) is wanted, then simply type the name of the variable which will form the initial argument to the command, followed by the name that will form the secondary argument to the command. If the command is not wanted, then simply parse two no-ops (one as the first argument, and one as the second). After each instruction set, the IP is advanced and wraps-around 4.

The structure of the Inc/Dec command arguments is: The first variable is the original value, the second variable is assigned to that value +/- 1. The structure of the 3rd and 4th commands are: If the initial variable is >0, then the second variable acquires the value "1", otherwise a "0". The 3rd command is the equivalent to the '[' in BF and thus the 4th command is the equivalent to the ']' in BF.

Example Code

Due to the laborious nature of programming in RFOL, I have only constructed one program thus far: Fibonacci. It loops infinitely producing successive Fibonacci numbers.

aa      bb  az  bccccz  aacc  czacccbz    bb      cc  bzcbbb  az

The interpreter

def Go(n='aa      aa  ab    aa  abaa'):
        p = 0
        k = 0
        var = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        while k<len(n):
                if ord(n[k]) in range(ord('a'),ord('z')+1):
                    if p==0:
                        var[ord(n[k+1])-97] = var[ord(n[k])-97] + 1
                       
                    elif p==1:
                        var[ord(n[k+1])-97] = var[ord(n[k])-97] - 1
                       
                    elif p==2:
                        if var[ord(n[k])-97]<=0:
                                var[ord(n[k+1])-97] = 0
                                t = 1
                                while t>0:
                                        k += 2
                                        if ord(n[k]) in range(ord('a'),ord('z')+1): t -= 1
                                        if t>0:
                                                k += 8
                                                if ord(n[k]) in range(ord('a'),ord('z')+1): t += 1
                                p = 3
                                k -= 2
                        else:
                                 var[ord(n[k+1])-97] = 1 
                    elif p==3:
                        if var[ord(n[k])-97]<=0:
                                var[ord(n[k+1])-97] = 0
                        else:
                                t = 1
                                while t>0:
                                        k -= 2
                                        if ord(n[k]) in range(ord('a'),ord('z')+1): t -= 1
                                        if t>0:
                                                k -= 6
                                                if ord(n[k]) in range(ord('a'),ord('z')+1): t += 1                                      
                                var[ord(n[k+1])-97] = 1
                                p = 1
                                k -=2
                    k += 2    
                else: k += 2
                print p,' -> ',var
                p += 1
                if p>3: p = 0


Thingy

Thingy is an unofficially endorsed meta-lang to RFOL, which I will not explain here

 def Thingy(n='+aa+bb[az+bc-cc[cz+aa-cc]cz+ac-cc[bz-bb-cc]bz+cb-bb]az'):
    n=filter(lambda a:not a.isspace(),n)
    k = 0
    p = 0
    r = 
    q = 0
    while k<len(n):
        if n[k]=='+':
            if p==0: p=4
            t = (4-p)
            p=0
            for q in range(t): r += '  '
        elif n[k]=='-':
            if p==2: p = 4    
            t = abs(1 - p)
            for q in range(t): r += '  '
            p=1
        elif n[k]=='[':
            t = abs(p - 2)
            for q in range(t): r += '  '
            p=2
        elif n[k]==']':
            t = abs(p - 3)
            for q in range(t): r += '  '
            p=3
        r += n[k+1] + n[k+2]
        p += 1
        if p>3: p =0
        k += 3
    return r