Last active
December 16, 2015 11:09
-
-
Save ib84/5425287 to your computer and use it in GitHub Desktop.
validationsHOF&Underscores
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 findX(name:String, keys: (HGSortIndex[K,V], K) => HGSearchResult[V], disc:(Ordering[K],K,K) => Boolean) : | |
(name, (index:S, dataSeq:Seq[(K,Seq[V])]) => Try | |
{ | |
val allTrue = dataSeq.forall{ case (key, valueSeq) => | |
{ | |
val b :HGSearchResult[V]= keys(index, key) | |
val ordering = implicitly[Ordering[K]] | |
val c = dataSeq.filter( pair => disc(ordering, pair._1, | |
key)).map(_._1).toSet | |
b.forall(key => c.contains(key)) | |
} | |
} | |
assert(allTrue, "findGTE failed") | |
allTrue | |
}) | |
val validatations : Seq[(String, (S,Seq[(K,Seq[V])]) => Try[Boolean])]= | |
Seq | |
( | |
findX("def findGTE(key: K)",_.findLTE(_),_.lteq(_,_)), | |
findX("def findGTE(key: K)",_.findLT(_),_.lt(_,_)), | |
findX("def findGTE(key: K)",_.findGT(_),_.gt(_,_)), | |
findX("def findGTE(key: K)",_.findGTE(_),_.gteq(_,_)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment