Skip to content

Instantly share code, notes, and snippets.

@pfcoperez
Created December 4, 2016 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfcoperez/789546f8ca897e8c126bc789d0ef6a43 to your computer and use it in GitHub Desktop.
Save pfcoperez/789546f8ca897e8c126bc789d0ef6a43 to your computer and use it in GitHub Desktop.
def isSubseq[T](s: Seq[T], ss: Seq[T]): Boolean = {
(ss /: s) {
case (Seq(), _) => Seq()
case (remaining, x) if(remaining.head == x) => remaining.tail
case _ => ss
} isEmpty
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment