Suppose I have
val dirty = List(\"a\", \"b\", \"a\", \"c\")
Is there a list operation that returns \"a\", \"b\", \"c\"
The algorithmic way...
def dedupe(str: String): String = { val words = { str split " " }.toList val unique = words.foldLeft[List[String]] (Nil) { (l, s) => { val test = l find { _.toLowerCase == s.toLowerCase } if (test == None) s :: l else l } }.reverse unique mkString " " }