Created
September 6, 2015 02:00
-
-
Save InvisibleTech/5e843afcfaf2006b4744 to your computer and use it in GitHub Desktop.
A recursive palindrome function. Needs to be case insensitive.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.immutable.StringOps._ | |
@annotation.tailrec | |
def isPalindrome(strSeq : IndexedSeq[Char]) : Boolean = strSeq match { | |
case _ if strSeq.size < 2 => true | |
case _ if strSeq.take(1) == strSeq.takeRight(1) => isPalindrome(strSeq.slice(1, strSeq.size-1)) | |
case _ => false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment