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

[copy//part] copy/part inconsistent ?

 [1/5] from: pwawood::mango::net::my at: 24-Nov-2004 8:00


I'm a bit confused about the behaviour of copy/part as it appears inconsistent:
>> str: "123456789"
== "123456789"
>> copy/part str find str "9"
== "12345678"
>> copy/part str index? find str "9"
== "123456789" I'm sure that I'm missing something, your thoughts would be appreciated. Regards Peter [mailed at 08:00 25/11/2004 GMT+8]

 [2/5] from: AJMartin::orcon::net::nz at: 24-Nov-2004 7:15


> I'm a bit confused about the behaviour of copy/part as it appears > inconsistent:
<<quoted lines omitted: 5>>
> == "123456789" >> index? str
== 1 The string index starts at 1, not 0. --- Andrew Martin Who's not dying! :) ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://valley.150m.com/

 [3/5] from: pwawood::mango::net::my at: 25-Nov-2004 16:30


Andrew and Gregg Thanks for your replies. It's particularly good to know that Andrew is now well enough to be answering mailing list questions. I'm slowly learning that in Rebol everything depends on the underlying value and not the word. This is just one case where things happen differently depending on the underlying value. There are a number of such instances which trip me up at regular intervals, the main one being when things return none rather than a value of the type I was expecting eg find "12345" "7". I guess this is one part of the thinking differently needed for Rebol. Regards Peter On Wednesday, Nov 24, 2004, at 12:21 Asia/Kuala_Lumpur, Gregg Irwin wrote:

 [4/5] from: greggirwin::mindspring::com at: 23-Nov-2004 21:21


Hi Peter, PWW> I'm a bit confused about the behaviour of copy/part as it appears PWW> inconsistent: PWW> >> str: "123456789" PWW> == "123456789" PWW> >> copy/part str find str "9" PWW> == "12345678" PWW> >> copy/part str index? find str "9" PWW> == "123456789" It may not be as clear as it could be from the help string, but it makes sense: /part -- Limits to a given length or position. range -- (Type: number series port pair) So, the distinction is that an integer (when you use INDEX?) specifies a length, while giving a series (the result of FIND STR "9") specifies a position (think of it as "up to" the position). -- Gregg

 [5/5] from: pwawood:mango:my at: 25-Nov-2004 16:30


Andrew and Gregg Thanks for your replies. It's particularly good to know that Andrew is now well enough to be answering mailing list questions. I'm slowly learning that in Rebol everything depends on the underlying value and not the word. This is just one case where things happen differently depending on the underlying value. There are a number of such instances which trip me up at regular intervals, the main one being when things return none rather than a value of the type I was expecting eg find "12345" "7". I guess this is one part of the thinking differently needed for Rebol. Regards Peter On Wednesday, Nov 24, 2004, at 12:21 Asia/Kuala_Lumpur, Gregg Irwin wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted