[REBOL] Re: Convert block inplace?
From: nitsch-lists:netcologne at: 25-Jul-2004 17:24
On Sonntag, 25. Juli 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.
!>> a: [%hi.txt %ho.txt]
== [%hi.txt %ho.txt]
!>> forall a [change a to-string first a]
== []
!>> a: head a ;if you need 'a later
== ["hi.txt" "ho.txt"]
> 2. 'swtich seems not to work with datatype! Is this a bug?
No, obfuscation. the word string! and the datatype string! look the same in
console.
'type? gives the datatype, switch uses the word.
solutions:
1) switch type?/word .. ;
2) switch type? reduce[ string! [] .. ] ; reduces makes the word string! the
datatype string! (because [get string!] gives the datatype)
-Volker