Table and Set Notation

« Resources
Notation Equivalent SML with SET and ORDSET
\[|X|\] size $S$
\[\{\}\] empty $()$
\[\{k\}\] singleton $k$
\[k \in S\] find $X$ $k$
\[X \cup \{k\}\] insert $(X, k)$
\[X \setminus \{k\}\] delete $(X, k)$
\[\{k \in X\ |\ e\}\] filterKey (fn $k$ => $e$) $X$
\[X \cup Y\] union $(X, Y)$
\[X \cap Y\] intersection $(X, Y)$
\[X \setminus Y\] difference $(X, Y)$
Notation Equivalent SML with TABLE and ORDTABLE
\[|T|\] size $T$
\[\{\}\] empty $()$
\[\{k \mapsto v\}\] singleton $(k, v)$
\[\{k \mapsto e : (k \mapsto v) \in T\}\] mapKey (fn $(k, v)$ => $e$) $T$
\[\{k \mapsto e : k \in X\}\] tabulate (fn $k$ => $e$) $X$
\[\{(k \mapsto v) \in T\ |\ e\}\] filterKey (fn $(k, v)$ => $e$) $T$
\[\{e_1 : (k \mapsto v) \in T\ |\ e_2\}\] mapKey (fn $(k, v)$ => $e_1$) (filterKey (fn $(k, v)$ => $e_2$) $T$)
\[T_1 \cup T_2\] union (fn (_, v) => v) $(T_1, T_2)$
\[T_1 \cap T_2\] intersection (fn (_, v) => v) $(T_1, T_2)$
\[T_1 \cap T_2\] difference $(T_1, T_2)$
\[\sum_{(k \mapsto v) \in T} e\] reduce add 0 (mapKey (fn $(k, v)$ => $e$) $T$)

The meaning of add and 0 in the reduce will depend on the type (e.g. Int.+ and 0 for integers or Real.+ and 0.0 for reals). We can also replace $\sum$ with other operations such as $\min$ and $\max$ with the implied semantics.