0

Having to represent the inversion of a KVP in a math formula, I would like to know how should I notate this principle?

I was going to use an inverted arrow above the letter representing the Key/value pair. Not to mention that I don't know how to represent a KVP within a formula, which would be helpful.

Thanks!

Khal_Tech
  • 103

1 Answers1

0

I assume you are talking about notation? So for dictionaries and key-value pairs we can think of it as a mapping between the set of keys $K$ and the set of values $V$. We write this mapping as the function $f$ from

$$ f:K\rightarrow V $$

Now say we have a value and want to find out what key is attributed to that value. This would be an inverse mapping. Note that this requires $f$ to be a bijection. We would notate this as

$$ f^{-1}:V\rightarrow K $$

where if $f(v)=k$ then $f^{-1}(k) = v$

wjmccann
  • 3,085
  • Hi. Thanks. I edited my question. Really helpful! – Khal_Tech Jul 18 '19 at 11:19
  • Hello back @ wjmccann. I assume I can't notate a dictionary as a set. How should I notate a dictionary in a math formula?

    The dictionary being s, I went with the following notation: ƒ(s) : a → b

    – Khal_Tech Jul 18 '19 at 15:08
  • You would have to notate a dictionary as a mapping between two sets. The keys and values each form a set that are mapped to each other via your function. This mapping function is however you set it, so it could have a closed form or not. – wjmccann Jul 18 '19 at 15:50
  • I will see how to do just this. I am not a math wiz, but this time, I need to put my coding on paper. The ƒ(s) : a → b is what I'll add, and in the description, I'll put that it's the mapping between subsets declared previously, by just giving these sets the name "a" and "b". Thanks for the help. – Khal_Tech Jul 18 '19 at 15:56