forked from rebol/rebol
-
Notifications
You must be signed in to change notification settings - Fork 2
Array
angerangel edited this page Mar 8, 2013
·
1 revision
ARRAY size /initial value
Makes and initializes a series of a given size.
ARRAY is a function value.
- size -- Size or block of sizes for each dimension (integer! block!)
-
/initial -- Specify an initial value for all elements
- value -- Initial value (will be called each time if a function)
#SOURCE
array: make function! [ [
"Makes and initializes a series of a given size."
size [integer! block!] "Size or block of sizes for each dimension"
/initial "Specify an initial value for all elements"
value {Initial value (will be called each time if a function)}
/local block rest
][
if block? size [
if tail? rest: next size [rest: none]
unless integer? set/any 'size first size [
cause-error 'script 'expect-arg reduce ['array 'size type? :size]
]
]
block: make block! size
case [
block? rest [
loop size [block: insert/only block array/initial rest :value]
]
series? :value [
loop size [block: insert/only block copy/deep value]
]
any-function? :value [
loop size [block: insert/only block value]
]
insert/dup block value size
]
head block
] ]