summaryrefslogtreecommitdiff
path: root/src/utils/TupleUtils.scala
blob: 2318c11a4e287cee243ee8fc6b32f1046b32b911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
package ixee.cryptopals.utils

import ixee.cryptopals.utils.FunctionUtils._

object TupleUtils {
  implicit class Tuple2[A, B](t: (A, B)) {
    def mapAll[C, D](_1: A => C = ident, _2: B => D = ident): (C, D) =
      (_1(t._1), _2(t._2))

    def <-:[C](f: A => C): (C, B) = (f(t._1), t._2)
    def :->[D](f: B => D): (A, D) = (t._1, f(t._2))
  }
}