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
def retry_with_backoff(success_func, backoff_rate=2, checkback_time=1): | |
def wrap(f): | |
def new_function(*args, **kw): | |
try: | |
f(*args, **kw) | |
try_in(checkback_time, retry, [checkback_time, args, kw]) | |
finally: | |
pass | |
def retry(delay, args, kw): |
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
List(1, 2, 3) |
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 logs: List[String] = aLotOfStrings | |
logs.map(_.takeWhile(_ != ' ')).grouped(8).count(_.contains("ERROR")) |
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
def nonview = (1 to 5000000).map(_ % 10).filter(_ > 5).reduce(_ + _) | |
def view = (1 to 5000000).view.map(_ % 10).filter(_ > 5).reduce(_ + _) |
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
var i,j,k = 0 | |
var x = 0L | |
while(i < 10000) { | |
while(j < 1000) { | |
while(k < 1000) { | |
x += 1 | |
k += 1 | |
} | |
k = 0; | |
j += 1 |
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
var x = 0L | |
for(i <- 0 to 10000; j <- 0 to 1000; k <- 0 to 1000) { | |
x += 1 | |
} |
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
(1 until 1000).count(_ % 10 == 0) |
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
var x = 1 | |
var num = 0 | |
while(x < 1000) { | |
if(x % 10 == 0) { num += 1 } | |
x += 1 | |
} |
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
(1 to 10) map (_ + 5) map (_ * 2) |
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
logs.view.map(_.takeWhile(_ != ' ')).grouped(8).count(_.contains("ERROR")) |
OlderNewer