Skip to content

Instantly share code, notes, and snippets.

@paulp
Created February 4, 2014 18:11
Show Gist options
  • Save paulp/8809154 to your computer and use it in GitHub Desktop.
Save paulp/8809154 to your computer and use it in GitHub Desktop.
"compute FIRST for binary alternatives" in check { (left: String, right: String) =>
import com.codecommit.util._
val leftFirst = if (left.length == 0) Set[Char]() else Set(left charAt 0)
val rightFirst = if (right.length == 0) Set[Char]() else Set(right charAt 0)
if (leftFirst.size == 0 || rightFirst.size == 0)
(left | right).first eq UniversalCharSet
else
(left | right).first == (leftFirst ++ rightFirst)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment