Skip to content

Instantly share code, notes, and snippets.

@sledorze
Created May 8, 2013 16:10
Show Gist options
  • Save sledorze/5541555 to your computer and use it in GitHub Desktop.
Save sledorze/5541555 to your computer and use it in GitHub Desktop.
failing function on coursera course.
def terrainFunction(levelVector: Vector[Vector[Char]]): Pos => Boolean =
{ case Pos(x,y) =>
try {levelVector(y)(x) != '-'} catch { case (e : IndexOutOfBoundsException) => false}
}
def findChar(c: Char, levelVector: Vector[Vector[Char]]): Pos = {
val y = levelVector.indexWhere(_.contains(c))
val x = levelVector(y).indexOf(c)
Pos(x, y)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment