In Standard ML, lists are the primary sequential data structure, similar to slices in Go. However, there are some key differences:
SML lists are homogeneous (all elements must be of the same type), while Go slices can be heterogeneous.
SML lists are immutable, whereas Go slices are mutable.
Adding elements to an SML list creates a new list, while appending to a Go slice modifies the existing slice.
The concepts of slicing and appending in Go are replaced with list operations like :: (cons), @ (concatenation), and functions from the List structure in SML.
Pattern matching in SML provides a powerful way to work with lists, which is not available in Go.
Note that SML doesn’t have a direct equivalent to Go’s make function for creating slices. Instead, lists are typically built using cons (::) or list literals.
The slices package utilities in Go can be mostly replaced by functions from the List structure in SML’s standard library.
While Go slices can have varying lengths in multi-dimensional structures, SML lists of lists can naturally have varying lengths without any special handling.