-- return 1st `n` chars of the `word` local function start(word, n) return word:sub(1, n) end; -- return true/false for palindrome/non-palindrome local function pali(word) -- half length of the `word` local hlen = #word / 2; -- 1st part of the word w/ middle char if any local half = start(word, hlen); -- construct a palindrome for the given word local half_r = start(word:reverse(), hlen); -- compare constructed polindrome with the initial word return half == half_r; end; -- print results print( pali( (...) or "" ) );