VL

From Esolang
Jump to: navigation, search

VL is esolang loosely based on vim commands.

It consists of the following internal registers:

  • value
  • pointer
  • index
  • int
  • pc


Where

value is the current value held (String, char or integer)

pointer is a pointer to one of 26 arrays (defaults to a at beginning of program)

index is the current index of the current array (defaults to 0 at beginning of program)

int is used for loops, repetition and comparisons

pc is the counter to the current instruction

Values in memory locations are initialised to 0.

Execution starts at the first character and reads instructions sequentially (unless moved by a jump).

Examples

Hello word:

iHello World!;W

Here, 'i' enters insert mode and any following characters up until an unescaped ';' are copied into value and the current memory location pointed at by pointer and index. Then 'W' writes out to stdout.


Output numbers 1 to 10:

10(aW)

Here the number 10 sets the int register which is the number of times that the following instruction is performed. Instructions can be grouped using parenthesis so this program runs 'aW' 10 times.

'a' increments the current memory location's value (which is 0 by default at the beginning of the program) and sets the value register to the result. Again 'W' writes to stdout.


Fibonacci Sequence (stopping at 144):

$ fibonacci sequence up to 50th term $
aW}aW           $ set initial two ones and position pointer on third $
'bi2;               $ 'b holds nth term counter $
v`a2{y2}p       $ set next number to previous $
{y}vy+p         $ increment by value of the previous previous $
W'ba50!2k    $ Write line and look until 'b is 50 $

anything between '$' pairs is ignored as a comment

'}' increases the index register. '{' decreases the index register.

'p' puts the current value register into the memory location currently being pointed at by pointer and index.

'y' copies the current memory location value into the value register.

'v' copies the value register value into the int register so vy+ will add the current memory location to the previous memory location.

'k' moves execution up a line, so '2k' moves 2 lines.

'!' makes the following jump conditional. '!' performs jump if value register != int register so here 50 sets the int register and checks against the value of 'b, if they are not equal then the following jump activates. '?' is a similar conditional which checks if value register == int register


See full command list on the interpreter github repo readme:

External resources

VL interpreter written in Rust