More functional way of writing this palindrome extractor? I wrote this palindrome extractor.  And even though it works, and I can solve the challenge with it, it feels very Java-like. I was wondering what adjustments I could make in order for it to be more functional.

import collection.mutable._

object Level1 {
    def palindrome(input:String) = input.reverse == input

    def extractPalindromes(input:String) = 
    {
        var counter = 0
        val palindromes = new ListBuffer[String]()
        while(counter &lt; input.length)
        {
            var localCounter = 2
            while((counter + localCounter) &lt; input.length)
            {
                //println("counter:"+counter+" localCounter:"+localCounter)
                val tempString = input.substring(counter, input.length - localCounter)
                if(palindrome(tempString)) palindromes += tempString
                localCounter += 1
            }       
            counter += 1
        }
        palindromes
    }

    def main(args:Array[String]) = {
        val input = "I like racecars that go fast"
        extractPalindromes(input).filter(_.length &gt; 4).foreach(println)
    }
}
It can be as simple as:

scala&gt; val str =  "I like racecars that go fast"
str: java.lang.String = I like racecars that go fast

scala&gt; for { i &lt;- 2 to str.size; s &lt;- str.sliding(i) if s == s.reverse} yield s
res5: scala.collection.immutable.IndexedSeq[String] = Vector(cec, aceca, racecar)