Skip to content

Instantly share code, notes, and snippets.

@liufengyun
Last active September 19, 2018 07:21
Show Gist options
  • Save liufengyun/4b60710181ad0230d54f25921b291a32 to your computer and use it in GitHub Desktop.
Save liufengyun/4b60710181ad0230d54f25921b291a32 to your computer and use it in GitHub Desktop.
first milestone
// all elements are `Int`, `N` is the size of the vector
trait Vector[N] {
def map(f: Int => Int): Vector[N]
def pad(x: Int): Vector[x + N]
def concat[M](v: Vector[M]): Vector[M + N]
def splitAt(i: Int): (Vector[i + 1], Vector[N - i - 1])
def slice(i: Int, j: Int): Vector[j - i + 1]
def dot(v: Vector[N]): Int
def size: Int
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment