Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Anyone can this code be written in less lines of code?

12 views
Skip to first unread message

Earl Montgomery

unread,
Apr 9, 2018, 1:49:37 PM4/9/18
to FalconPL
function is_palindrome(a)
a = strUpper(a).replace(" ", "")
b = a[-1:0]
return b == a
end

a = "mom"
> is_palindrome(a)

Earl Montgomery

unread,
Apr 9, 2018, 9:14:25 PM4/9/18
to FalconPL
thought it over for a minute
b = "mom"
> strUpper(b).replace(" ", "") == strUpper(b[-1:0]) ? "Is a palindrome" : "Is not a palindrome"

Earl Montgomery

unread,
Apr 9, 2018, 9:24:03 PM4/9/18
to FalconPL
is this a crazy idea
this:
b = "mom"
> strUpper(b).replace(" ", "") == strUpper(b[-1:0]) ? "Is a palindrome" : "Is not a palindrome"

instead being something like:

the input would pull in from the keyboard or wherever and the $_ would be whatever was
typed in the keyboard.  I might have gotten the $_ idea from PowerShell.
 
> strUpper(input()).replace(" ", "") == strUpper($_[-1:0]) ? "Is a palindrome" : "Is not a palindrome"=

Just my imagine at it again.

On Monday, April 9, 2018 at 1:49:37 PM UTC-4, Earl Montgomery wrote:

Giancarlo Niccolai

unread,
Apr 10, 2018, 5:34:15 AM4/10/18
to FalconPL
I got this

return (b=a.uppper().replace(" ","")) and b[-1:0] == b

supposing that an empty string must not be considered a palindrome...
Reply all
Reply to author
Forward
0 new messages