Skip to content

Instantly share code, notes, and snippets.

@sumew
Last active November 26, 2020 06:33
Show Gist options
  • Save sumew/99628dcb35e7ad98ff564e22a4a9d82a to your computer and use it in GitHub Desktop.
Save sumew/99628dcb35e7ad98ff564e22a4a9d82a to your computer and use it in GitHub Desktop.
A window that can expand to the right and contract from the left
case class Window(l: Int, r: Int) {
def size = r - l
def ||->(i: Int): Window = this.copy(r = r + i) //widen by moving right edge right
def |->|(i: Int): Window = this.copy(l = l + i) //shrink by moving left edge right
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment