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

[REBOL] Re: manipulating values in blocks

From: joel:neely:fedex at: 27-Nov-2002 14:03

Hi, Hugues, Here's one way, below... Hugues Moisy wrote:
> Hi List, > > I manage to manipulate a block like [1 17 23 36 49 58], representing limits off segments, ie, if i have 6 values in the block, it seems that the block contains 5 segments (1-17, 17-23, 23-36 ...) > > is there anyone who knows how to manipulate the block into getting start and end values of each segment ? I've tried, but don't know how to do this job. >
bounds-to-segs: func [b [block!] /local left result] [ result: make block! (length? b) - 1 left: first b foreach right next b [ insert/only tail result reduce [left right] left: right ] result ] ... which behaves as ...
>> bounds-to-segs [1 17 23 36 49 58]
== [[1 17] [17 23] [23 36] [36 49] [49 58]] ... or can be used as ...
>> foreach seg bounds-to-segs [1 17 23 36 49 58] [
[ print head insert next copy seg "-" [ ] 1 - 17 17 - 23 23 - 36 36 - 49 49 - 58 HTH! -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446