makeArray (Array)

makeArray ( value size -- array )

Creates an array of a given size and fills it with a given value.

makeArray ( range -- array )

Creates an array from a range, the array's elements will be aliases of the elements of the input range.

makeArray ( list -- array )

Creates an array from a builtin-list, the array's elements will be aliases of the elements of the input builtin-list.

Arguments

makeArray ( value size -- array )

The

value
to copy into each array element.
size
is the number of elements in the array, integer.

makeArray ( range -- array )

The

range
to alias elements from.

makeArray ( list -- array )

list
is the builtin-list to alias elements from.

Return values

The resulting

array
.

Complexity

makeArray ( value size -- array )

O(size), where size is second parameter.

makeArray ( range -- array )

O(size), where size is the number of elements in an input range.

makeArray ( list -- array )

O(size), where size is the number of elements in an input list.

Example

"sl/array" useFile a1: (1 2 3) makeArray; a2: 1 3 makeArray; a3: a1.makeRange makeArray copy; a1 [print "," print TRUE] enum LF print a2 [print "," print TRUE] enum LF print a3 [print "," print TRUE] enum
Output:
1,2,3, 1,1,1, 1,2,3,