val answers = Iterator.from(10, 1).filter( | |
Foo(_).test(isPalindrome) | |
) | |
println(answers.next) | |
def isPalindrome(base: String): Boolean = | |
base == base.reverse | |
case class Foo(n: Integer) { | |
lazy val decimal: String = Integer.toString(n) | |
lazy val octal: String = Integer.toOctalString(n) | |
lazy val binary: String = Integer.toBinaryString(n) | |
def test(f: String => Boolean): Boolean = | |
f(decimal) && f(octal) && f(binary) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment