Skip to content

Instantly share code, notes, and snippets.

@InvisibleTech
Created September 6, 2015 02:00
Show Gist options
  • Save InvisibleTech/5e843afcfaf2006b4744 to your computer and use it in GitHub Desktop.
Save InvisibleTech/5e843afcfaf2006b4744 to your computer and use it in GitHub Desktop.

Revisions

  1. InvisibleTech created this gist Sep 6, 2015.
    8 changes: 8 additions & 0 deletions palindrome.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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
    }