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

[REBOL] Re: getting rid of empty string in a block.

From: greggirwin:mindspring at: 13-Mar-2002 11:27

Hi Stephane, << 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 ? >> I don't know if this is the best solution, but it's nice and general: remove-if: func [predicate blk args /local result keep-it][ result: make block! length? blk repeat el blk [ ; Have to use a temp variable here. "if" doesn't like "predicate :el args" ; inline and putting it in parens breaks the evaluation. keep-it: not predicate :el args if keep-it [append/only result :el] ] return result ]
>> remove-if :empty? ["" "A" "B" "" "C" "D" ""] none
== ["A" "B" "C" "D"] --Gregg