How to represent a map data structure mathematically
-
05-11-2019 - |
Question
Wondering how to represent a map object such as the following mathematically:
var foo = {
a: 10,
b: 'bar',
c: true
}
You could say that it was a function like this:
foo(x, y, z)
where $x$ is an integer, $y$ is a string, and $z$ is a boolean. But the question then is how to say the names of the keys a, b, c
. Something like:
foo(label(x, a), label(y, b), label(z, c))
But then wondering about how type theory deals with this, so I' a bit confused. Wondering how computer science would model this data structure using mathematical notation. Maybe:
$$ \begin{align*} foo = \left\{ \begin{array}{r@{}l} & a = x \\ & b = y \\ & c = z \end{array} \right\} \end{align*} $$
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange