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 distinctBy[A, B](f: A => B)(list: List[A]): Iterable[A] = | |
list.zip(list.map(f)) | |
.groupBy { case (_, k) => k } | |
.values | |
.filter(_.size == 1) | |
.map(_.headOption) | |
.collect { case Some((e, _)) => e } | |
def duplicatesBy[A, B](f: A => B)(list: List[A]): List[A] = | |
list.diff(distinctBy(f)(list).toList).distinct |
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
object BCDDate { | |
/** | |
* Method creates local date from BCD (https://en.wikipedia.org/wiki/Binary-coded_decimal) encoded hex string | |
* | |
* @param bcdDate HEX representation of BCD date | |
* @return local date instance | |
*/ | |
def apply(bcdDate: HexString): Try[LocalDate] = | |
Try { |