Rebol 编程/数组
外观
< Rebol 编程
ARRAY size /initial value
创建并初始化给定大小的序列。
ARRAY 是一个函数值。
- 大小 -- 每个维度的大小或大小块 (类型: 整数块)
- /initial -- 为所有元素指定一个初始值
- 值 -- 初始值 (如果为函数,则每次调用时都会调用) (类型: 任何)
- 捕获
array: func [ "Makes and initializes a series of a given size." [catch] 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 pick size 1 [ throw-error 'script 'expect-arg reduce ['array 'size type? get/any '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 ]