Who can explain why in
http://rosettacode.org/wiki/Forward_difference#NetRexx arr=Rexx[10] causes an exception that goes away with arr=Rexx[11] I can't see where I would use an index of 11 old and blind? Thanks in advance Walter PS It's pretty cool to translate (good!?!) Rexx to NetRexx! _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
NetRexx arrays are origin 0. Since you are starting your iteration with 1, you need to have 11 elements otherwise you go over the bounds of the array.
Rick
On Sat, Aug 18, 2012 at 11:49 AM, Walter Pachl <[hidden email]> wrote: Who can explain why in _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by christel.u.w.pachl christel.u.w.pachl
I though something lile that. Thanks!
so arr[10] allocates arr(0:9) in PL/I terms and using a[10] causes the exception. I though something like that. Thanks! ---- Rick McGuire <[hidden email]> schrieb: > NetRexx arrays are origin 0. Since you are starting your iteration with 1, > you need to have 11 elements otherwise you go over the bounds of the array. > > > Rick > > On Sat, Aug 18, 2012 at 11:49 AM, Walter Pachl <[hidden email] > > wrote: > > > Who can explain why in > > http://rosettacode.org/wiki/Forward_difference#NetRexx > > arr=Rexx[10] causes an exception that goes away with arr=Rexx[11] > > I can't see where I would use an index of 11 > > old and blind? > > Thanks in advance > > Walter > > PS It's pretty cool to translate (good!?!) Rexx to NetRexx! > > > > _______________________________________________ > > Ibm-netrexx mailing list > > [hidden email] > > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > > > _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 18 August 2012 10:44, Walter Pachl <[hidden email]> wrote: I though something lile that. Thanks! While all you say is true; a more Rexxy way to do this is by using an indexed string (AKA associative array) which acts much more like a Rexx stem than an array does. Here's an example which I hope explains it more clearly:
/* NetRexx */ options replace format comments java crossref symbols nobinary
nums = '90 47 58 29 22 32 55 5 55 73' arry = Rexx[nums.words() + 1] -- define a zero based array
stem = '' -- initialize a Rexx indexed string loop i = 1 to nums.words() arry[i] = nums.word(i) stem[i] = nums.word(i)
end i say loop x = 0 to arry.length - 1
say 'arry['x']='String.valueOf(arry[x])', \-' end x
say say loop x = 1 to nums.words()
say 'stem['x']='stem[x]', \-' end x
say return
Output: arry[0]=null, arry[1]=90, arry[2]=47, arry[3]=58, arry[4]=29, arry[5]=22, arry[6]=32, arry[7]=55, arry[8]=5, arry[9]=55, arry[10]=73,
stem[1]=90, stem[2]=47, stem[3]=58, stem[4]=29, stem[5]=22, stem[6]=32, stem[7]=55, stem[8]=5, stem[9]=55, stem[10]=73,
Alan. Can't tweet, won't tweet! _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
Alan
-- Needs more cowbell. |
In reply to this post by christel.u.w.pachl christel.u.w.pachl
---- Alan Sampson <[hidden email]> schrieb:
> On 18 August 2012 10:44, Walter Pachl <[hidden email]> wrote: > > > I though something lile that. Thanks! > > so arr[10] allocates arr(0:9) in PL/I terms and using a[10] causes the > > exception. > > I though something like that. Thanks! > > > > While all you say is true; a more Rexxy way to do this is by using an > indexed string (AKA associative array) which acts much more like a Rexx > stem than an array does. Thanks. Amazing. Program changed accordingly Walter PS: GS claims that Rexx Version 1 is readable! _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |