[REBOL] creation of a block with a lot of integers
From: peoyli:algonet:se at: 5-Oct-2000 16:55
Hi,
Is there a efficient way of creating a block consisting of a range of
integers..
using a for-loop is ok for a small amount of values, but when reaching
1000 values, it takes about 2 seconds on a 060 equipped Amiga, 2000
values takes about 8 seconds, and so on...
also.. is this supposed to function like this (local variable is not
cleared between function calls) ?
REBOL []
maybe-bug: func [
min [integer!]
max [integer!]
/local testblock temp
][
testblock: []
for temp min max 1 [ insert testblock temp ]
testblock
]
>> do %../REBOL/bug.r
Script: "Untitled" (none)
>> maybe-bug 1 5
== [5 4 3 2 1]
>> maybe-bug 1 5
== [5 4 3 2 1 5 4 3 2 1]
>> maybe-bug 1 5
== [5 4 3 2 1 5 4 3 2 1 5 4 3 2 1]
>>
A work-around, appending a 'clear testblock' after the testblock: []
will fix this, but shouldn't testblock: [] do it in the first place ?
/PeO