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

[REBOL] Re: Change/part

From: gjones05:mail:orion at: 23-Feb-2001 9:34

From: Paul Tretter
> >> string: "0000000000" > == "0000000000" > >> series? string > == true > >> change/part string "2" 4 > == "000000" > >> print head string > 2000000 > >> > > Doesn't give me the result I expected. I index 4 of the string to be
2 . On first blush, I initially thought the same, then I remembered replace does that. So I figured that 'change was meant to target a different problem space. If I understand it correctly, change normally changes whatever is pointed to by the index, namely what is at first (reminds me of the Abbot and Costello routine). The /part modification allows additional elements to be changed out. So in your example above, change starts at 'first and strips out to the fourth position, then replaces these with the replcement value. This appears to be the behavior that I obtained and is suggested above. To be sure that I have the concept correct about 'change, I double checked the /Core pdf. Another example: string: "1234000056" ;yields "1234000056" string: skip string 4 ;yields "000056" change/part string "2" 4 ;yields "56" string: head string ;yields "1234256" The 4 "0"'s are changed to a "2". Hope this helps. --Scott