Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Convert block inplace?

From: roland::hadinger::arcor::de at: 25-Jul-2004 17:55

On Sunday 25 July 2004 16:31, Robert M. Münch wrote:
> Hi, I'm trying to convert a block of values in place to other types. > Exmaple: > > a: [%hi.txt %ho.txt] > > convert-block a string! > > should gibe: > > a: ["hi.txt" "ho.txt"] > > Some questions: > 1. How can I change the block in place inside the function? I tried > 'forall but I can't referr to the "current" entry. > 2. 'swtich seems not to work with datatype! Is this a bug?
And for issue 2: made the same mistake... I guess you're trying: switch type? element [ integer! [ ... ] string! [ ... ] ... ] If you look at the source code of the switch mezzanine, you'll see it's basically just a 'do and a 'select. The select function takes a series as-is and searches it (without reducing the series if it's a block). So everything inside the switch block is either a word! or a block! (not a datatype!). You have to reduce the switch block to get datatype! values. switch type? element reduce [ integer! [ ... ] ... ] HTH -- R.