Reverse String in Erlang

Published on 06 October 2019 (Updated: 21 November 2023)

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

Current Solution

-module(reverse_string).
-export([main/1]).

%%--------------------------------------------------------------------
%% Reverse a given string
%%--------------------------------------------------------------------
reverse_string(String) ->
   lists:reverse(String).

main(Args) ->
    if
        length(Args) >= 1 ->
            Str = lists:nth(1, Args);
        true ->
            Str = ""
    end,

   ReverseStr = reverse_string(Str),
   io:format("~s~n", [ReverseStr]).

Reverse String in Erlang 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.