Examples of reduce functions that are injective?

99 views Asked by At

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
0

There are 0 answers