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

Change/part

 [1/16] from: ptretter:norcom2000 at: 22-Feb-2001 23:05


Anyone have problems with Windows based /View with Change/part? Paul Tretter

 [2/16] from: gjones05:mail:orion at: 23-Feb-2001 6:03


From: Paul Tretter
> Anyone have problems with Windows based /View with Change/part?
I haven't used it much in my programs to date, but I ran it through some tests to see if it worked as expected. It seemed to work fine in Windows 98 and /View 0.10.38.3.1. For what its worth... --Scott

 [3/16] from: ptretter:norcom2000 at: 23-Feb-2001 8:30


Maybe, I am using it wrong -
>> help change
USAGE: CHANGE series value /part range /only /dup count DESCRIPTION: Changes a value in a series and returns the series after the change. CHANGE is an action value. ARGUMENTS: series -- Series at point to change (Type: series port) value -- The new value (Type: any) REFINEMENTS: /part -- Limits the amount to change to a given length or position. range -- (Type: number series port) /only -- Changes a series as a series. /dup -- Duplicates the change a specified number of times. count -- (Type: number)
>> 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". Paul Tretter

 [4/16] from: gjones05:mail:orion at: 23-Feb-2001 9:34


From: Paul Tretter
> >> string: "0000000000" > == "0000000000"
<<quoted lines omitted: 6>>
> >> > 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

 [5/16] from: robbo1mark:aol at: 23-Feb-2001 10:55


I think the command you want to be using is 'POKE which changes a series value at a given index position. Mark Dickson OSCAR: :REBOL

 [6/16] from: ryanc:iesco-dms at: 23-Feb-2001 10:11


I agree that something is wrong here Paul, For one the docs dont accurately describe what change does. "Changes a value in a series and returns the series after the change." I would say "Changes a value in a series and returns the part of the series after the change." Moving onto to change/part, "Limits the amount to change to a given length or position," is not entirely accurate since its return value indicates that the whole of the range was changed. If what it does is not a bug, it would be somewhat more accurately said "Enforces change limited to a given length or position." This all brings to mind a question. Does anyone know the purpose of change returning the part of the series after the change, as opposed to the whole of the changed series? --Ryan Paul Tretter wrote:
> Maybe, I am using it wrong - > >> help change
<<quoted lines omitted: 47>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. -Einstein

 [7/16] from: jelinem1:nationwide at: 23-Feb-2001 13:01


Just to provide another opinion, I had absolutely no problem understanding and using 'change/part from the REBOL documentation. Also, "a part of a series" IS "a series", is it not? I use the return of 'change when I am traversing a series and finding elements (or imbedded series) to change. I am not necessarily changing the sub-series with the same size series. The return from 'change provides a convienient way of pointing to where the next element in the (original) series is. I see no need to change'change or its documentation. Perhaps reading about and learning the use of 'replace helps understand the usefulness of 'change? - Michael Jelinek Ryan Cole <[ryanc--iesco-dms--com]>@rebol.com on 02/23/2001 12:11:04 PM From: Ryan Cole <[ryanc--iesco-dms--com]>@rebol.com on 02/23/2001 12:11 PM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: [rebol-list--rebol--com] cc: Subject: [REBOL] Re: Change/part I agree that something is wrong here Paul, For one the docs dont accurately describe what change does. "Changes a value in a series and returns the series after the change." I would say "Changes a value in a series and returns the part of the series after the change." Moving onto to change/part, "Limits the amount to change to a given length or position," is not entirely accurate since its return value indicates that the whole of the range was changed. If what it does is not a bug, it would be somewhat more accurately said "Enforces change limited to a given length or position." This all brings to mind a question. Does anyone know the purpose of change returning the part of the series after the change, as opposed to the whole of the changed series? --Ryan Paul Tretter wrote:
> Maybe, I am using it wrong - > >> help change
<<quoted lines omitted: 32>>
> > > > I haven't used it much in my programs to date, but I ran it through
some
> > tests to see if it worked as expected. It seemed to work fine in > > Windows 98 and /View 0.10.38.3.1.
<<quoted lines omitted: 11>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. -Einstein

 [8/16] from: andrew:wxc at: 24-Feb-2001 7:59


It was written:
> > >> help change > > USAGE: > > CHANGE series value /part range /only /dup count > > > > DESCRIPTION: > > Changes a value in a series and returns the series after the
change.
> For one the docs dont accurately describe what change does. "Changes a
value in a series and returns the series after the change." I would say Changes a value in a series and returns the part of the series after the change. Um, the docs are accurate here. Watch:
>> s: "1234567890"
== "1234567890"
>> r: change s "def"
== "4567890"
>> print head r
def4567890
>> s
== "def4567890" Note that 's and 'r are the same string.
> Moving onto to change/part, "Limits the amount to change to a given length
or position," is not entirely accurate since its return value indicates that the whole of the range was changed. If what it does is not a bug, it would be somewhat more accurately said "Enforces change limited to a given length or position."
> > REFINEMENTS: > > /part -- Limits the amount to change to a given length or position. > > range -- (Type: number series port) >> s: "1234567890"
== "1234567890"
>> r: change/part s "defghi" 2
== "34567890"
>> print head r
defghi34567890
>> print s
defghi34567890 Note that positions 1 and 2 in s have been replaced with the string defghi . A length of "2" from the start of the string.
>> s: "1234567890"
== "1234567890"
>> r: change s "defghi"
== "7890"
>> print head r
defghi7890
>> print s
defghi7890 Note that the first six characters of the string have been replaced. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [9/16] from: andrew:wxc at: 24-Feb-2001 8:20


Paul wrote:
> >> string: "0000000000" > == "0000000000"
<<quoted lines omitted: 5>>
> 2000000 > Doesn't give me the result I expected. I index 4 of the string to be "2".
Try:
>> string: "0000000000"
== "0000000000"
>> change at string 4 "2"
== "000000"
>> string
== "0002000000" Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [10/16] from: andrew:wxc at: 24-Feb-2001 8:31


Ryan wrote:
> Does anyone know the purpose of change returning the part of the series
after the change,... So you can do neat things like (from Spell.r): WordEnd: change/part WordStart Correction WordEnd and then move the 'parse position like: ) :WordEnd Or, a smaller example: parse string [ some [ start: ":" copy word some Alpha end: ( end: change/part start form do load word end ) :end ] ]
> ...as opposed to the whole of the changed series?
Actually, it returns all the string, but the position of the string is after the change. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [11/16] from: robbo1mark:aol at: 23-Feb-2001 15:18


I'll repeat again..........8-) POKE is the function you want to change a value at a series index position see below;
>> string: "0000000000"
== "0000000000"
>> poke string 4 #"2"
== "0002000000"
>>
make sense? Mark Dickson

 [12/16] from: lmecir:mbox:vol:cz at: 23-Feb-2001 22:05


Hi, try to read http://www.rebolforces.com/series.html It might give you some info. Regards Ladislav

 [13/16] from: andrew:wxc at: 24-Feb-2001 10:11


Mark wrote:
> I'll repeat again..........8-) > POKE is the function you want to change a value at a series index position
<<quoted lines omitted: 3>>
> >> poke string 4 #"2" > == "0002000000"
And 'change is better if you want to change a lot of values at once:
>> string: "0000000000"
== "0000000000"
>> change at string 4 "ABC"
== "0000"
>> string
== "000ABC0000" Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [14/16] from: ryanc:iesco-dms at: 23-Feb-2001 14:33


When I read "Changes a value in a series and returns the series after the change," I would expect to get the entire series back as so...
>> change "1234567890" "test"
== "test567890" ;not the real return value!!! I make this assumption because I take the "after" to mean later in time by default. If it said it "returns the series before the change," I would expect it to return the series as it was before the change occured. While not as inaccurate as I first interpeted this sentence, a slight change in wording could help clarify. Unfortuneately my suggested correction was not any better, "changes a value in a series and returns the part of the series after the change." Since as Andrew pointed out, it really is not returning the part, but more precicesly the position. How about this definition: "Changes a value in a series and returns the series behind the change." I think that says it quite well. Anyhow, Andrew, I like your real example of using changes return value. I thought later on that RT may have chosen this return value mainly because the other positions relating to the change function are much easier to obtain. Returning the head would be non-standard and is so easily obtained with 'head. It probably boiled down to returning the before position or the behind the changed position. Since the before position is readily available, the behind the changed position seems the obvious choice. --Ryan Andrew Martin wrote:

 [15/16] from: t-man:onemain at: 24-Feb-2001 1:24


howdy all! This change/part seems a throwback to snobol/spitbol, where the .rem returned the remainder. So I would document it as "Changes a value in a series and returns the remainder. There's a regular expression equivalent like $' or something. This allows further changes on into the series without having to re-determine where you are/what's left. It makes a lot more sense when the series is large, because you are operating on a smaller and smaller portion of the series every go around. I've just started learning rebol, or I'd build a little code chunk that might demonstrate a likely usage of change/part in this manner. T ----- Original Message ----- From: "Ryan Cole" <[ryanc--iesco-dms--com]> To: <[rebol-list--rebol--com]> Sent: Friday, February 23, 2001 12:11 PM Subject: [REBOL] Re: Change/part I agree that something is wrong here Paul, For one the docs dont accurately describe what change does. "Changes a value in a series and returns the series after the change." I would say "Changes a value in a series and returns the part of the series after the change." Moving onto to change/part, "Limits the amount to change to a given length or position," is not entirely accurate since its return value indicates that the whole of the range was changed. If what it does is not a bug, it would be somewhat more accurately said "Enforces change limited to a given length or position." This all brings to mind a question. Does anyone know the purpose of change returning the part of the series after the change, as opposed to the whole of the changed series? --Ryan Paul Tretter wrote:
> Maybe, I am using it wrong - > >> help change
<<quoted lines omitted: 47>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world. -Einstein

 [16/16] from: lmecir::mbox::vol::cz at: 24-Feb-2001 14:25


Hi,
> How about this definition: "Changes a value in a series and returns > the series behind the change." I think that says it quite well.
The wording that I am suggesting is in http://www.rebolforces.com/series.html CHANGE doesn't return the original Series. It skips the affected Places to facilitate subsequent changes. Regards Ladislav

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