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
| export JAVA_HOME=`/usr/libexec/java_home -v 1.8` | |
| launchctl setenv JAVA_HOME `/usr/libexec/java_home -v 1.8` |
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
| trait Account { | |
| def interest: Int | |
| } | |
| object Account { | |
| val slabs = List((1000, 1), (5000, 2), (Int.MaxValue, 3)) | |
| def apply(amount: Int): Account = new Account { | |
| override def interest = { |
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
| def curry[A,B,C](f: (A, B) => C): A => (B => C) = { | |
| (a:A) => (b:B) => f(a, b) | |
| } | |
| def uncurry[A,B,C](f: A => B => C): (A, B) => C = { | |
| (a:A, b:B) => f(a)(b) | |
| } | |
| def compose[A,B,C](f: B => C, g: A => B): A => C = { | |
| (a:A) => f(g(a)) |
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
| object MyOption { | |
| def none[A] = new MyOption[A] { | |
| def cata[X](s: A => X, n: => X) = n | |
| override def toString = "none" | |
| } | |
| def some[A](a: A) = new MyOption[A] { | |
| def cata[X](s: A => X, n: => X) = { | |
| s(a) | |
| } |