[REBOL] Array under 1.2.8 was Re: Re: Sort by first part of line
From: rotenca::telvia::it at: 8-Sep-2002 17:59
Hi Joel and all,
> I should have pointed out that the modified algorithm below splits
> the group number from the remainder of the line; therefore, some
> post-processing might be needed to re-attach the three-digit prefix
> to the data (unless, of course, the subsequent processing could use
> the bucket index for that purpose). So the time comparison may not
> be comletely fair.
This is a little true for all the test we made, someone use read/lines,
someone read, someone ends with a block of line, someone with a block of
blocks. More "exact" tests should be made with a file on disk and stop with a
file on disk.
A note, this does not work as one expect under 1.2.8:
buffer: copy/deep array/initial 999 []
the correct expression under 1.2.8 is:
buffer: array/initial 999 
copy/deep is no more useful, and series now are well initialized.
But the new array is too slow, here it is my patched version. I should like to
know if works without errors and/or if soemone finds others optimizations:
array-patched: func [
[catch] ;PATCH: added
"Makes and initializes a series of a given size. patched by ana"
size [integer! block!] "Size or block of sizes for each dimension"
/initial "Specify an initial value for all elements"
value "Initial value"
/local block rest
if not initial [value: none]
if block? size [
rest: next size
if tail? rest [rest: none]
size: first size
if not integer? size [make error! "Integer size required"]
block: make block! size
either rest [
loop size [
;if series? value [value: copy/deep value] ;PATCH: removed
insert/only tail block throw-on-error [array/initial rest value]
;PATCH: added tail and throw-on-error
either series? value [
loop size [insert/only tail block copy/deep value] ;PATCH: added
insert/dup block value size ;PATCH: removed block:
block ;PATCH: removed head