Hi Felix

This is one of the standard REBOL gotchas.  The assignment list: [] creates
a literal block and all subsequent references are to the same block.  That
is why it just gets longer and longer.  To do what you want use

list: copy []

which will create a new empty block each time it executes.

HTH

Larry

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 22, 2000 3:16 PM
Subject: [REBOL] strange


Hi!

I have the following code:

num: 30
to: load %file
until [
  list: []
  print length? list
  loop num [
    elem: first to
    if elem [ append list elem ]
    to: next to
  ]
  print length? list
  print "---"
  tail? to
]

It gives

0
30
---
30
60
---
60
90
---
90
120
---
120
150

Shouldn't list length be set to zero by
list: []
???

Felix P|tsch

--
http://www.ph-cip.uni-koeln.de/~puetsch
Of course I'm crazy, but that doesn't mean I'm wrong.


Reply via email to