# Sequence Notation

 Notation Equivalent SML with SEQUENCE library $S[i]$ nth $S$ $i$ $|S|$ length $S$ $\langle \; \rangle$ empty () $\langle v \rangle$ singleton $v$ $\langle i, \ldots, j \rangle$ tabulate (fn k => $i$ + k) ($j$ - $i$ + 1) $S \langle i, \ldots, j \rangle$ subseq $S$ ($i$, $j$ - $i$ + 1) $\langle e : p \in S \rangle$ map (fn $p$ => $e$) $S$ $\langle e : 0 \leq i < n \rangle$ tabulate (fn $i$ => $e$) $n$ $\langle p \in S \;|\; e \rangle$ filter (fn $p$ => $e$) $S$ $\langle e_1 : p \in S \;|\; e_2\rangle$ map (fn $p$ => $e_1$) (filter (fn $p$ => $e_2$) $S$) $\langle e : p_1 \in S_1,\; p_2 \in S_2 \rangle$ flatten (map (fn $p_1$ => map (fn $p_2$ => $e$) $S_2$) $S_1$) $\langle e : 0 \leq i < n,\; 0 \leq j < i \rangle$ flatten (tabulate (fn $i$ => tabulate (fn $j$ => $e$) $i$) $n$) $\sum_{p \in S} e$ reduce add 0 (map (fn $p$ => $e$) $S$) $\sum_{i = k}^n e$ reduce add 0 (map (fn $i$ => $e$) $\langle k, \ldots, n\rangle$)

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.