Created
September 28, 2014 14:18
-
-
Save aoiroaoino/efb3398bd868f40d7a78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._, Scalaz._ | |
type Field = Vector[Vector[Option[String]]] | |
object Field { | |
def update(x: Int, y: Int): PLens[Field, Option[String]] = { | |
PLens.vectorNthPLens(y) >=> PLens.vectorNthPLens(x) | |
} | |
} | |
def updateDot(x: Int, y: Int, s: String)(field: Field) = { | |
Field.update(x,y).set(field, Some(s)) | |
} | |
val f = Vector.fill(3)(Vector.fill(3)(Option.empty[String])) | |
updateDot(0,0,"aaa")(f) | |
// => res13: Option[Field] = Some(Vector(Vector(Some(aaa), None, None), Vector(None, None, None), Vector(None, None, None))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment