[REBOL] Re: Limitation coming from the "initialize" refinement usedwith the "Array" word
Hi Joel, thanks for correcting me -L - Original Message - From: "Joel Neely" Hi, Ladislav, Ladislav Mecir wrote: > > Hi Gerard, > > instead of > > tab_nbr/:L/:C: 20 > > which doesn't work you can use: > > 1) > change at at tab_nbr L C 20 > Perhaps change at first at tab_nbr L C 20 is what you meant??? As in >> table0 == [[0 0] [0 0] [0 0]] >> at at table0 1 1 == [[0 0] [0 0] [0 0]] >> at first at table0 1 1 == [0 0] >> change at first at table0 1 1 17 == [0] >> table0 == [[17 0] [0 0] [0 0]] -jn- -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Limitation coming from the "initialize" refinement usedwith the "Array" word
Joel and Ladislav Wrote : > Hi, Ladislav, > > Ladislav Mecir wrote: > > > > Hi Gerard, > > > > instead of > > > > tab_nbr/:L/:C: 20 > > > > which doesn't work you can use: > > > > 1) > > change at at tab_nbr L C 20 > > > > Perhaps > > change at first at tab_nbr L C 20 > > is what you meant??? As in > > >> table0 > == [[0 0] [0 0] [0 0]] > >> at at table0 1 1 > == [[0 0] [0 0] [0 0]] > >> at first at table0 1 1 > == [0 0] > >> change at first at table0 1 1 17 > == [0] > >> table0 > == [[17 0] [0 0] [0 0]] Thanks Joel and Ladislav, this is something I will explore as it is probably faster than my actual way of doing things. Regards, Gerard -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Limitation coming from the "initialize" refinement usedwith the "Array" word
Hi Gerard, Gerard Cote wrote: > Hello, <...> > Here is my example code ( I tried it directly at the concole) : > > tab_nbr: array/initial [3 2] 0 cells contents are all initialized to > the 0 value > L: 2 > C: 1 > tab_nbr/2/1: 10cell content [2 1] is updated to 10 > print tab_nbr/:L/:CI verify that all is OK > > tab_nbr/:L/:C: 20But this one doesn't work, so I > dynamically generated the real line and asked > REBOL to execute it. > The wanted expression was > : tab_nbr/2/1: 20 > and this can be given by > join join join join "tab_nbr/" L join "/" C ": " 20 >which generates == > "tab_nbr/2/1: 20" then the "do" word will do it like this. There are a lot of ways to make this work, but sometimes it pays to think about what arrays really are: blocks of blocks, so the most elegant solution (IMO) is to use change at tab_nbr/:L C 20 And, btw, it is _much_ faster: >> profiler/test [do join join join join "tab_nbr/" L join "/" C ": " 20] 100 == [0:01:07.580636] >> profiler/test [change at tab_nbr/:L C 20] 100 == [0:00:02.855449] <...> > While I am at it, I also tried to use the word "reduce" and a to-block > conversion instead of the word "do" but it seems that the refered object > (tab_nbr) is not in the same context. > > So is there a way to notify REBOL that we want it to share some valuable > information from a context to another one or do we have to define it for the > global one, which in this case is not under my control Yup, it's 'bind. >> reduce bind to-block join join join join "tab_nbr/" L join "/" C ": " 30 'tab_nbr == [[30 0]] >> tab_nbr == [[0 0] [30 0] [0 0]] 'bind has two paramters, the block you want to run in a differrent context than its default, and a word from the context you want it to run in. I hope that helps, Ingo -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
[REBOL] Re: Limitation coming from the "initialize" refinement usedwith the "Array" word
thats nice Gerard a bit prettier do rejoin['tab_nbr "/" l "/" c ": " 20] On Wed, 26 Jun 2002, Gerard Cote wrote: > Hello, > > As I tried to generate a dynamic line of code to create a way to circumvent > the way REBOL interprets the ARRAY notation when used with variable indexes > instead of numeric constants (nothing really hard with REBOL), I found some > limitation with the initialize refinement as following : It seems only > possible to use the same constant (a scalar value or any other datatype > seems to be is accepted) as the initial value used by the Array word itself. > > Here is my example code ( I tried it directly at the concole) : > > tab_nbr: array/initial [3 2] 0 cells contents are all initialized to > the 0 value > L: 2 > C: 1 > tab_nbr/2/1: 10cell content [2 1] is updated to 10 > print tab_nbr/:L/:CI verify that all is OK > > tab_nbr/:L/:C: 20But this one doesn't work, so I > dynamically generated the real line and asked > REBOL to execute it. > The wanted expression was > : tab_nbr/2/1: 20 > and this can be given by > join join join join "tab_nbr/" L join "/" C ": " 20 >which generates == > "tab_nbr/2/1: 20" then the "do" word will do it like this. > > do join join join join "tab_nbr/" L join "/" C ": " 20 > > But now that I can use real variable indexes with my array, am I supposed to > use loops too just to get > any cell value initialized with something other than some constant like the > series of values : 10, 20 , 30 , 40 50 and 60. I think yes > Would it not be simpler to have something like this : > > tab_nbr: array/initial/series [3 2] 10 60 10 where the start, stop and > increment values would be respectively 10 60 and 10. > > IS this already possible in another way that I am not aware of ? > > While I am at it, I also tried to use the word "reduce" and a to-block > conversion instead of the word "do" but it seems that the refered object > (tab_nbr) is not in the same context. > > So is there a way to notify REBOL that we want it to share some valuable > information from a context to another one or do we have to define it for the > global one, which in this case is not under my control > > Thanks to all for any clue if any, > > Gerard > > > > > - Original Message - > From: "Gregg Irwin" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, June 26, 2002 1:00 PM > Subject: [REBOL] Re: making objects from block content > > > > Hi Again, > > > > As an addenduem, it may not work at all in your case as LOAD will very > > likely not recognize numbers as valid set-words. > > > > --Gregg > > > > > > -- > > To unsubscribe from this list, please send an email to > > [EMAIL PROTECTED] with "unsubscribe" in the > > subject, without the quotes. > > > > -- > To unsubscribe from this list, please send an email to > [EMAIL PROTECTED] with "unsubscribe" in the > subject, without the quotes. > -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.