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
| for { | |
| (k, v) <- tiers | |
| n <- filteredData if (n \ "metricPath").text.contains(v) | |
| } yield k -> bts.filter(n \ "metricPath".text.contains).foldLeft(List[Transaction]()) { | |
| case (agg, bt) => { | |
| val trans = Transaction(bt, k) | |
| trans.metricData = Metric(n) | |
| bt :: agg | |
| } | |
| } |
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 fib: Stream[Int] = { | |
| def loop(i:Int, j:Int):Stream[Int] = { | |
| j #:: loop(j, i+j) | |
| } | |
| loop(1,1) | |
| } |
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 loopOver(xs: List[Int]) = { | |
| val vs = xs.toStream | |
| def loop(rem:Int):Stream[Stream[Int]] = rem match { | |
| case 0 => for(v <- vs) yield Stream(v) | |
| case n => for(head <- vs; tails <- loop(n-1)) yield head #:: tails | |
| } | |
| for(i <- Stream.from(0); items <- loop(i)) yield items | |
| } |
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 GetTC[A,B,T[_]] { | |
| type C | |
| implicit def aToC(a:A):C | |
| implicit def bToC(b:B):C | |
| def get: T[C] | |
| } | |
| trait LowPriorityGetTC { | |
| implicit def getTC1[A,B,T[_]](implicit ac: A => B, tc:T[B]) = new GetTC[A,B,T] { | |
| type C = B |