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
class Job(): | |
def __init__(self, *args, **kwargs): | |
pass | |
def __call__(self, data): | |
raise NotImplementedError() | |
class Square(Job): | |
def __call__(self, data): | |
return [d * d for d in data] |
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
val primes: Stream[Int] = 2 #:: Stream.from(3).filter { n => !primes.takeWhile(_ <= math.sqrt(n)).exists(n % _ == 0) } | |
def isPrime(n: Int) = primes.dropWhile(_ < n).head == n |