Skip to content
John Reppy edited this page Sep 2, 2015 · 1 revision
structure Array : ARRAY

We propose three new functions for the Array module.

This page is part of proposal 2015-003.


Synopsis

val toList     : 'a array -> 'a list
val fromVector : 'a vector -> 'a array
val toVector   : 'a array -> 'a vector

Description

  • toList arr

returns the list of the elements of the array `arr`.
  • fromVector vec

returns a new array that is initialized to the content of the vector `vec`.
  • toVector vec

returns a vector of the elements of the array `arr`.

Discussion

The toVector function is the same as the existing vector function, but it follows the toType/fromType naming convention.

Rationale

The toList operation complements the existing fromList and can be implemented more efficiently than by using List.tabulate. Adding the fromVector and toVector functions help reduce the friction of converting between different sequence types.