Reverse String in Never

Published on 28 April 2022 (Updated: 25 September 2022)

Reverse String in Never

Welcome to the Reverse String in Never page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

>func print_str(hw[L] -> int) -> int
{
    func __print(hw[L] -> int, i -> int) -> int
    {
        i < L ? { print(hw[i]); __print(hw, i + 1) } : 0
    }
    __print(hw, 0)
}

func reverse(hw[L] -> int) -> [_] -> int
{
    let rev = {[ L ]} -> int;
    
    func __reverse(hw[L1] -> int, rev[L2] -> int, i -> int) -> int
    {
        i < L1 ? { rev[L2 - i - 1] = hw[i]; __reverse(hw, rev, i + 1) } : 0 
    }
    __reverse(hw, rev, 0);

    rev
}

func main() -> int
{
    let hw = [ 72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33 ] -> int;
    
    print_str(reverse(hw))
}

Reverse String in Never was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.