LNUSP

From Esolang
Jump to: navigation, search

LNUSP is a language with a two-dimensional data space and code space and 5 commands.

LNUSP is intended as an improved PATH with better orthogonality and fewer commands. Another noticeable difference is that LNUSP allows the memory pointer to move diagonally, as well as horizontally and vertically. It was created by User:Zzo38, and the name means Low-SNUSP.

Source code format

Source code is specified in an unusual way in LNUSP. Each line begins with a three-digit number specifying how many times the rest of the line should repeat. For example,

000 ;This example program #1
000     .INPUT        .OUTPUT
001     @
007     ++
003      **

expands to produce the following code, when run:

    @
    ++
    ++
    ++
    ++
    ++
    ++
    ++
     **
     **
     **

Command set

+ Increase current memory cell by 1, mod 256
* Move memory pointer in the direction the IP is traveling
? Turn 45 degrees left if current memory cell is nonzero
! Turn 45 degrees left if current memory cell is zero
@ Save position and go north, or if there is already a
  position saved, go back to that position and delete the
  saved position, or if already going north, unconditionally
  turn 45 degrees right

. (dot) is specially guaranteed to not do anything. The program starts in the top left corner going southeast.

Subroutines

Going off the north side of the program results in a subroutine being executed, followed by the instruction pointer reversing direction. Which subroutine is executed depends on how far over the column is from the left. With the leftmost column counting as 1, the columns are

  • 8 = Input
  • 24 = Output
  • 41 = Stop

Example

This example works like the UNIX cat, copying its input to its output until EOF is read.

000 1234567890123456789012345678901234567890123456789
000        .INPUT          .OUTPUT          .STOP
001 .      .               .                .
001  .?......!!................?            .
001  ?.    .!  !           .    ?           .
001  ? .   .!  !           .    ?           .
001   ?.!..@..!............@...?            .
001           !.............................@

See also

  • PATH, LNUSP's inspiration.
  • SNUSP, another improved PATH.

External resources