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

[REBOL] Re: Block manipulation: help!

From: joel::neely::fedex::com at: 13-Jun-2002 9:42

Hi, Mat, You're almost there! Here's a complete example (using a string for the original raw data)... rawdata: { Saloon:Red Coupe:Red Coupe:Yellow Pickup Truck:Red Pickup Truck:Yellow Pickup Truck:Orange Pickup Truck:Blue } finaldata: [] foreach line parse/all rawdata "^/" [ if parse/all line [ copy type to ":" skip copy color to end ][ either colors: select finaldata type [ if none? find colors color [ append colors color ] ][ append finaldata reduce [ type reduce [color] ] ] ] ] foreach [type colorlist] finaldata [ print [type ":" tab colorlist] ] Mat Bettinson wrote:
> CarLines: read/lines %file > > foreach CarLine CarLines [ > Car: pick (parse CarLine none) 1 > Colour: pick (parse CarLine none) 2 > ; > ; ??? > ; > ] >
... or, more simply... foreach carline read/lines %file [ ;... ] since you can use the block of lines directly in FOREACH.
> ; > ; But how do we poke it back? We don't have a position to do a poke? > ;
You don't. Blocks are mutable values, so when you APPEND to a block you are modifying its content -- even if it happens to live inside another block. Hope this helps! -jn-