# SML/NJ Library Manual

## The `MONO_DYNAMIC_ARRAY` signature

#### Synopsis

> `signature `MONO_DYNAMIC_ARRAY`
> `

The MONO_DYNAMIC_ARRAY signature specifies an interface to dynamic monomorphic arrays. These act like arrays of unbounded length.

#### Interface

> `type elem
> type array
> val array : (int * elem) -> array
> val subArray : (array * int * int) -> array
> val fromList : (elem list * elem) -> array
> val tabulate : (int * (int -> elem) * elem) -> array
> val default : array -> elem
> val sub : (array * int) -> elem
> val update : (array * int * elem) -> unit
> val bound : array -> int
> val truncate : (array * int) -> unit
> `

#### Description

`type elem`
`type array`
`array (sz, el)`
  creates a dynamic array all of whose elements are initialized to the default value of el. The sz parameter is used as a hint of the potential range of indices of non-default items. Raises Size if sz < 0.
`subArray (arr, lo, hi)`
  creates a new array with the same default as arr, and whose values in the range [0,hi-lo] are equal to the values in arr in the range [lo, hi]. Raises Size if hi < lo.
`fromList (l, el)`
  creates an array using the list of values l plus the default value el.
`tabulate (sz, f, el)`
  acts like Array.tabulate, plus stores the default value el. Raises Size if sz < 0.
`default arr`
  returns the array's default value.
`sub (arr, i)`
  returns value of the array at index i. If that value has not been set by `update`, it returns the default value. Raises Subscript if i < 0. Note that no exception is raised for an index too large.
`update (arr, i, el)`
  sets the value at index i of the array arr to el. Raises Subscript if i < 0. Note that no exception is raised for an index too large.
`bound arr`
  returns an upper bound on the index of values that have been changed.
`truncate (arr, sz)`
  makes every entry in arr with index greater than sz the default value.

#### See Also

> DynamicArrayFn, MONO_ARRAY

[ Top | Parent | Contents | Index | Root ]

Last Modified June 9, 1998
Comments to John Reppy
Copyright © 1998 Bell Labs, Lucent Technologies