Palindrome detection: Difference between revisions
Content deleted Content added
ReeceGoding (talk | contribs) m →{{header|R}}: Syntax highlighting. |
ReeceGoding (talk | contribs) m →{{header|R}}: Improved syntax. |
||
Line 4,512: | Line 4,512: | ||
Unicode is supported, but this ignores the "inexact palindromes" extra credit requirement because, without some sort of regex, supporting Unicode while stripping punctuation and white space is hard in R. |
Unicode is supported, but this ignores the "inexact palindromes" extra credit requirement because, without some sort of regex, supporting Unicode while stripping punctuation and white space is hard in R. |
||
<lang rsplus>is.Palindrome<-function(string) |
<lang rsplus>is.Palindrome <- function(string) |
||
{ |
{ |
||
characters<-unlist(strsplit(string,"")) |
characters <- unlist(strsplit(string, "")) |
||
all(characters==rev(characters)) |
all(characters == rev(characters)) |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |