User:HaleyHalcyon

From Esolang
Jump to navigation Jump to search

MarioLANG test cases

The code is run on the sandbox at TIO.run.

Multiple elevators on the same X coordinate

Code

    >   :!
    "=====
>   !
====#
    >  +:!
    "=====

Output

0

Comments

This code tests which exit is used if multiple exits exist for the same X coordinate. Depending on which exit is taken, the number printed changes between 0 and 1.

0 is printed, because elevators prefer the exit immediately above itself.

Note to self: Remember to stop Mario before he takes the elevator.

Jump height testing

Code

        >:
    >:
> + ^ + ^ !
===========

Output

1

Comments

In the 2D Mario games, Mario tends to be able to jump 5 grid spaces. This is a test to see how many grid spaces Mario can jump in MarioLANG.

If Mario can reach the >, the jump height is printed. Disappointingly, this test indicates that the Mario in MarioLANG can only jump 1 grid space before he succumbs to the inexorable pull of gravity.

Wall/floor interchangeability

Code

> :      : =
====||||====

Output

0 0
�[31;1mMario somehow got stuck.�[0m

Comments

This code snippet demonstrates that the blocks = and | only differ in aesthetics, and are functionally interchangeable.

In the middle portion, Mario walks on the floor made of wall.

In the end portion, Mario gets stuck on the wall made of floor.

Wall/floor interchangeability part 2

Code

>
====
      : !
====|====
     +: !
=========

Output

0

Comments

This tests the description from the documentation that "If Mario has no ground below his feet he falls until he lands on either ground or EOF". However, this statement is false, as Mario is also stopped by the section of walls.

Cat program

Code

>, +[<
"====-
!   . !
#======

Input

It's-a me, Mario!

Output

It's-a me, Mario!

Comments

This is a simpler program that operates on the same design as the Truth Machine, with the looping removed.

This demonstrates that (at least in the implementation on TIO.run) if there is no character to be input, the input is treated as ÿ, which is Character 255.

First, Mario gets a character as input, or ÿ if there is no input left. This value is temporarily incremented to test if the input is ÿ, in which case the < is skipped, and Mario stops at the ledge ending in !.

Otherwise, Mario first decrements the value back, and outputs the character with .. Mario then returns to the top left to read the next character.

Visible Whitespace (draft)

Visible Whitespace is a relex of Whitespace where all commands (which are represented by whitespace characters in Whitespace) are given a visible representation. Visible Whitespace code must be passed through a Visible Whitespace Transpiler before it can be executed by a Whitespace interpreter or compiler.

Visible Whitespace is not intended to be used as its own language, but as a more user-friendly way to write Whitespace code.

In the code samples below, all Whitespace code is represented with s, t, and n replacing space, tab, and newline, respectively, in the interest of brevity and, crucially, visibility.

Number literals

To stay true to Whitespace as much as possible without being too annoying, Visible Whitespace accepts numbers in the following format:

Numbers
Lang. Sign Binary value Terminator
WS s for positive, t for negative s for 0, t for 1 \n
VWS + or - As many 0 or 1 as needed #

Any time `number` or `label` appears in the command’s declaration, they are taken to be in this notation.

Commands

IMPs
VWS WS Command
IO tn I/O
Stack s Stack manipulation
Math ts Arithmetic
Flow n Flow control
Heap tt Heap access

As with Whitespace, the output commands discard the output item after use.

IO
Command WS Meaning
IO.char_in() tn.ts Read a character and push its value to the stack.
IO.num_in() tn.tt Read a number and push its value to the stack.
IO.char_out() tn.ss Output the top of the stack as a character.
IO.num_out() tn.st Output the top of the stack as a number.
Stack
Command WS Meaning
Stack.push(number) s.s Push number to the stack.
Stack.copy() s.ns Duplicate the item on the top of the stack.
Stack.swap() s.nt Swap the top two items on the stack.
Stack.discard() s.nn Discard the top item on the stack.
Stack.copy_nth(number) s.ts(#) Get the nth item in the stack and push a copy onto the stack. (Added in WS 0.3)
Stack.slide_n(number) s.tn(#) Set aside the top item of the stack, discard the next n items, then push the top item back on. (Added in WS 0.3)
Math
Command WS Meaning
Math.plus() ts.ss Add the top 2 items on the stack and push the result.
Math.minus() ts.st Subtract the top 2 items on the stack (first pushed goes on the left) and push the result.
Math.times() ts.sn Multiply the top 2 items on the stack and push the result.
Math.divide() ts.ts Divide the top 2 items on the stack (first pushed goes on the left) and push the integer quotient.
Math.modulo() ts.tt Divide the top 2 items on the stack (first pushed goes on the left) and push the remainder.
Flow
Command WS Meaning
Flow.label(label) n.ss(#) Declare a label in the program.
Flow.call(label) n.st(#) Jump to the given label as a subroutine.
Flow.return() n.tn() End a subroutine and return to where it was called.
Flow.jump(label) n.sn(#) Unconditionally jump to a label.
Flow.if_zero(label) n.ts(#) Jump to a label if the top of the stack is 0.
Flow.if_negative(label) n.tt(#) Jump to a label if the top of the stack is negative.
Flow.halt() n.nn() Ends the program.

The Heap IMP allows storage and retrieval of data in arbitrary addresses in the Whitespace interpreter or compiler’s virtual memory.

Heap commands operate on the top two items of the stack. The first to be pushed is the address, then the second to be pushed is the value.

Heap
Command WS Meaning
Heap.set() tt.s() Store a value in an address.
Heap.get() tt.t() Retrieve a value in an address.

Visible Whitespace was first defined and transpiler implemented in Python by Haley Halcyon.