50 women blame CRM for providing software to its customer
Mar. 27th, 2019
kind of improvement
Mar. 27th, 2019 06:36 pmJust figured out how to calculate elements of yx for two sets (passed here as lists)
An element of an exponential is a
An element of an exponential is a
Map[X, Y]
./** * Set of all possible maps from set xs to set ys * @param xs domain of maps * @param ys codomain of maps * @tparam X type of domain elements * @tparam Y type of codomain elements * @return the set of all possible maps */ def exponent[X, Y](xs: Set[X], ys: Set[Y]): Set[Map[X, Y]] = { setOf(allMaps(xs.toList, ys.toList), pow(ys size, xs size), (m: Map[X, Y]) => xs == m.keySet ) } def allMaps[X, Y](xs: List[X], ys: List[Y]): List[Map[X, Y]] = (List(Map.empty[X, Y]) /: xs)((maps, x) => maps flatMap (m => ys map (y => m + (x -> y))) )