Palindrome detection: Difference between revisions
Content deleted Content added
Add APL entry |
|||
Line 3,195: | Line 3,195: | ||
$CharArray = $Text.ToCharArray() |
$CharArray = $Text.ToCharArray() |
||
[Array]::Reverse($CharArray) |
[Array]::Reverse($CharArray) |
||
$Text - |
$Text -eq [string]::join('', $CharArray) |
||
} |
} |
||
</lang> |
</lang> |
||
===PowerShell (Regex Version)=== |
===PowerShell (Regex Version)=== |
||
This version is much faster because it does not manipulate arrays. |
This version is much faster because it does not manipulate arrays. [This is not clear; the above version was slowed down by using -join instead of [string]::join, and -like instead of -eq. After changing those it is similar, if not faster, than this version]. |
||
<lang PowerShell> |
<lang PowerShell> |
||
function Test-Palindrome |
function Test-Palindrome |