How to resolve the algorithm Palindrome detection step by step in the Erlang programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Palindrome detection step by step in the Erlang programming language

Table of Contents

Problem Statement

A palindrome is a phrase which reads the same backward and forward. Write a function or program that checks whether a given sequence of characters (or, if you prefer, bytes) is a palindrome. For extra credit:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Palindrome detection step by step in the Erlang programming language

Source code in the erlang programming language

-module( palindrome ).

-export( [is_palindrome/1, task/0] ).

is_palindrome( String ) -> String =:= lists:reverse(String).

task() ->
	display( "abcba" ),
	display( "abcdef" ),
	Latin = "In girum imus nocte et consumimur igni",
	No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ),
	display( Latin, No_spaces_same_case ).



display( String ) -> io:fwrite( "Is ~p a palindrom? ~p~n", [String, is_palindrome(String)] ).

display( String1, String2 ) -> io:fwrite( "Is ~p a palindrom? ~p~n", [String1, is_palindrome(String2)] ).


  

You may also check:How to resolve the algorithm Anti-primes step by step in the BASIC programming language
You may also check:How to resolve the algorithm SHA-1 step by step in the Python programming language
You may also check:How to resolve the algorithm Align columns step by step in the Smalltalk programming language
You may also check:How to resolve the algorithm Sorting algorithms/Selection sort step by step in the R programming language
You may also check:How to resolve the algorithm Vector products step by step in the AppleScript programming language