[REBOL] Re: getting rid of empty string in a block.
From: micael::gullmes::telenordia::se at: 13-Mar-2002 20:17
here is a different approach:
>> foreach i t [if not equal? "" trim i [print i]]
This will also get rid of lines containing spaces.
hope it helps.
Fran: Bansard Stephane [mailto:[p0665393--MAGELLAN--UMontreal--CA]]
Skickat: den 13 mars 2002 17:39
Amne: [REBOL] getting rid of empty string in a block.
I want to sort a file by line alphabetic order. It appears it works at once
write an idea ! Rebol is great !
str: copy 
foreach l (sort read/lines %my-file) [append str join l "^/"]
But I haven't thought of blank line which are empty string in the sort
read/lines resulting block.
I try using the string length. But I don't understand the following
>> t: ["" "" "one" "two"]
>> foreach i t [print length? i]
>> foreach i t [if length? i [print i]]
>> foreach i t [if length? i <> 0 [print i]]
** Script Error: length? expected series argument of type: series port tuple
** Near: if length? i <> 0
>> foreach i t [if (length? to-string i <> 0) [print i]]
What would be the best solution to get rid of the empty strings ? (or of any
empty values of a block, be they string or of any type? Could you give me a
pointer to the explanation of this in the official doc ?