Skip to content

Instantly share code, notes, and snippets.

@arkadijs
Created May 15, 2015 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arkadijs/6d23db339cf666991481 to your computer and use it in GitHub Desktop.
Save arkadijs/6d23db339cf666991481 to your computer and use it in GitHub Desktop.
Give meaningful names, improve code, write some tests.
def a(b: List[AnyRef]): List[String] =
b.foldLeft(List[String]())((c, d) => d match {
case null => c
case e: String => c :+ e
case f: List[AnyRef] => c ++ a(f)
})
def g(h: List[String]) =
h.foldLeft(List[String]())((i, j) => i.lastOption match {
case Some(`j`) => i
case _ => i :+ j
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment