hi again for your second question an answer that will undoubtably be improved opon is:
>> unset [n1 n2 total diff] >> set['n1 'n2 'total 'diff] compose[15 25 (does [n1 + n2]) (does [n2 - n1])] == [15 25 func [][n1 + n2] func [][n2 - n1]] >> print [n1 n2 total diff] 15 25 40 10 >> for the first part- though there are far better solutions than the one I offered I am not seeing a glitch. (REBOL/Core 2.5.0.3.1 on w98) >> a: array/initial [3 2] 0 == [[0 0] [0 0] [0 0]] >> r: 2 c: 1 d: 0 == 0 >> print a/:r/:c 0 >> do rejoin['a "/" r "/" c ": " 10] == [10 0] >> print a/:r/:c 10 >> a == [[0 0] [10 0] [0 0]] >> for i 1 3 1[for j 1 2 1[do rejoin['a "/" i "/" j ": " d: d + 10]]] == [50 60] >> a == [[10 20] [30 40] [50 60]] On Thu, 27 Jun 2002, Gerard Cote wrote: > Hello Tom, > > > Tom Conlin wrote : > > > > a bit prettier > > do rejoin['tab_nbr "/" l "/" c ": " 20] > > > > You're almost right but a small glitch appeared in your version. The final > one should be : > > do rejoin["tab_nbr/" L "/" C ": " 20] > > instead of my original one : > > > > 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 > > > > > Thanks for the "cue". As you can see below, even if I knew the effect of the > "reduce" word - when used alone, I didn't think to use it, at least in the > form you submitted me - that is with the combined "rejoin" word. > > And the worst here is that when confronted with this face-to-face encounter > I quickly told myself : Wow! It could have been great if the "join" word had > been used with so many parameters as I had under the hand. I simply missed > it but be sure that next time I'll try harder !!! > > But as I have grabbed your attention for a moment, can I submit you another > question which I also asked myself when confronted with this other coding > example I tried a couple of days ago while submitting it to a friend of mine > who want to start in REBOL - don't worry about the apparent difficulty level > for this intro to REBOL because he is already doing professional coding in > other programming languages and I was effectively comparing many ways to do > the same thing - assignment (multiple ones in this case) : > > The original try was : > > set [ 'n1 'n2 'total 'diff ] [ 15 25 n1 + n2 n2 - n1] <-- > the error is pointing n1 as having no value > print [n1 n2 somme diff] > while trying to eval n1 + n2 > > The expected result was : 15 25 40 10 > > but I had to rearrange it according to one of these alternatives to get the > expected result : > > a) set [ 'n1 'n2 ] [ 15 25 ] > set 'somme n1 + n2 > set 'diff n2 - n1 > > b) set [ 'n1 'n2 ] [ 15 25 ] > set ['somme 'diff ] reduce [ n1 + n2 n2 - n1 ] > > c) set [ 'n1 'n2 ] [ 15 25 ] > set ['somme 'diff ] compose [ (n1 + n2) (n2 - n1) ] > > > And the related question : Is there is a way for REBOL to assign many > variables simultaneously (that is in a pseudo-parallel form on the same line > instead of serializing them by putting them on many successive lines) like I > was able to do in the Lisp language with the LET (for parallel assignment) > and LET* (for serial assignment) statements. > > I know this is just a purist question for academicians but I'd like to know > if this is possible or not with REBOL as it is now > > Thanks, > Gerard. > > > > 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. > > > > > > -- > 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.
