August 23, 2024

P06 - Find out whether a list is a palindrome.

Example:

> p06:is_palindrome([1,2,3,2,1]).
    true

erlang

% Find out whether a list is a palindrome.

%
% We check whether the list reversed is the same as itself
%
-module(p06).
-export([is_palindrome/1]).

is_palindrome(Ls) ->
    Ls == p05:reverse(Ls).
    
Be first to comment
Leave a reply