0

Are there any sources to find common map-reduce functions that are injective ? (Is there a name for such functions ?)

For example, I need to map a list of numbers

lst = [1,2,3,4]

into a tuple (sum, product)

def mapper(lst):
    sum_, prod = 0, 1
    for e in lst:
        sum_ += e
        prod *= e
res = mapper(lst)
# res = tuple(10, 24)

But this mapping is not injective because lists:

x = [1,2,3,4]
y = [4,3,2,1]

produce the same result.

I don't particularly care about the "difficulty" of inverting those functions, but different sources for easy and hard invertible functions would be helpful.

Also, it would be nice if the result wouldn't "explode" in range. For example the function:

def mapper(lst):
    res = 1
    for e, prime in zip( lst, prime_number_generator() ):
        res *= prime**e

is a map-reduce and also injective but the result would be:

res = 2^1 * 3^2 * 5^3 * 7^4 = 2 * 9 * 125 * 2401 = 5402250 # too large number
  • It's pretty clear why sum and product is not injective: it commutes. For example `[1,2]` and `[2,1]` gives the same results. So you're looking operation that is at least not commutative. – mathfux Feb 04 '20 at 11:20
  • Also, it's pretty clear that there's no unit, I mean a number A such that A*x = x*A = x for any other number x. – mathfux Feb 04 '20 at 11:27
  • And while this problem is getting something not that easy from sections of abstract algebra, you need to know whether your mapping needs to be injective on lists that have diiferent lengths. – mathfux Feb 04 '20 at 11:31

0 Answers0