Last active
November 27, 2019 04:47
-
-
Save kmizu/a229857d15a3d14b50416c2efec266af to your computer and use it in GitHub Desktop.
CS Study 2019/11/27
This file contains hidden or 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
case class Point(x: Int, y: Int) | |
def traverse(p: Point): Int = p match { | |
case Point(3, 3) => | |
1 | |
case Point(x, y) if x <= 3 && y <= 3 => | |
traverse(p.copy(x = p.x + 1)) + | |
traverse(p.copy(y = p.y + 1)) | |
case Point(_, _) => | |
0 | |
} | |
traverse(Point(1, 1)) // 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment