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

[REBOL] Interleaving strings -How? Re:

From: rebol:techscribe at: 21-Sep-2000 21:45

Hi Webdev,
>At bare minimum I need to understand the command >syntax for stepping and clipping >the string at specific points as well as the >method for specifying the length of >the clipped portion.
This should get you started skip
>> string: "0123456789"
== "0123456789"
>> string: skip string 3
== "3456789"
>> string
== "3456789"
>> head string
== "0123456789"
>> string: head string
== "0123456789"
>> string
== "0123456789"
>> string skip tail string -3
== "789" at
>> string: at string 3
== "23456789"
>> string
== "23456789"
>> string: head string
== "0123456789" back
>> string back tail string
== "9" next
>> string: next string
== "123456789"
>> string: head string
== "0123456789" copy/part
>> partial-string: copy/part string 3
== "012"
>> partial-string
== "012"
>> partial-string: copy/part skip string 3 2
== "34"
>> partial-string
== "34" Creating a string from an integer
>> string: form 1234
== "1234"
>> string
== "1234" Another way to do it
>> string: ""
== ""
>> insert string 1
== ""
>> append string 2
== "12" picking and poking
>> string
== "12"
>> pick string 1
== #"1"
>> pick string 2
== #"2"
>> poke string 2 #"X"
== "1X" Hope this helps At 11:30 PM 9/21/00 -0400, you wrote:
> Dear "Fellow Rebol Rousers", After having read the docs I have not >quite figured out how to accomplish the interleaving of strings. The >short and the long of what I want to do is take latitude and longitude >coordinate pairs and interleave them with each other. The rational >behind this is to place objects that are physically close to each other in >the real world close together in computer memory, which we all know is >linear and not spherical like the earth. The coordinates are in decimal >degrees for the sake of easy manipulation. The max longitude is 180 >degrees while the max latitude is 90. >Ignore the issue of positive/negative values as indications of north/south >east/west locations. The first segment of the numbers would be >interleaved on the basis of the non decimal portion of their values (1st >three positions assuming required zero padding). >The balance of the values would be interleaved on each subsequent pair. >As an example: 043.6732452849 > 142.8321724625 interleaved value: 043142 6783 3221 4572 2846 4925 >(spaces are only for readability/illustration) The non decimal portion >must be padded with a zero for all latitude values (they never exceed 90). ><100. I understand that I must convert the numbers to rebol strings to >access the necessary functionality required to step through the "number" >and pluck out the required portion. My problem: At bare minimum I need >to understand the command syntax for stepping and clipping the string at >specific points as well as the method for specifying the length of the >clipped portion. >Any inspiration would be most appreciated. Thanks in advance, >[webdev--accglobal--net]
;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com