= #JxnPortable\docs\programmer_examples\demos\IndexAccessDemo.jxn

da7 = 10. + { 0 : 6 }  ! double array
 = { 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (double[7])
al7 = KmgStaticUtilities.toArrayList @Double da7  ! java.util.ArrayList has methods get(int) and size()
 = [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0] (java.util.ArrayList)
ra7 = @JxnRealArrayAlgebra da7  ! JxnRealArrayAlgebra has methods get(int) and size()
 = {10.0, 11.0 ... 16.0}[7] (JxnRealArrayAlgebra)


da7[0]  ! first array element
 = 10.0 (double)
da7[-7]  ! same via negative index
 = 10.0 (double)
da7[6]  ! last array element
 = 16.0 (double)
da7[-1]  ! same via negative index
 = 16.0 (double)


da7[  1 : ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (double[6])
da7[ -6 : ]  ! same result for negative index
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (double[6])
da7[  5 : ]
 = { 15.0, 16.0 } (double[2])
da7[ -2 : ]
 = { 15.0, 16.0 } (double[2])

al7[  1 : ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (java.lang.Double[6])
al7[ -6 : ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (java.lang.Double[6])
al7[  5 : ]
 = { 15.0, 16.0 } (java.lang.Double[2])
al7[ -2 : ]
 = { 15.0, 16.0 } (java.lang.Double[2])

ra7[  1 : ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (double[6])
ra7[ -6 : ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 } (double[6])
ra7[  5 : ]
 = { 15.0, 16.0 } (double[2])
ra7[ -2 : ]
 = { 15.0, 16.0 } (double[2])


da7[  1 :  5 ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[  1 : -2 ]  ! same result for negative index
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[ -6 :  5 ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[ -6 : -2 ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[{  1 :  5 }]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[{ -6 : -2 }]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
da7[{  1 : -2 }]  !! -> da7[{ 1, 0, -1, -2 }]
 = { 11.0, 10.0, 16.0, 15.0 } (double[4])
da7[{ 1, 0, -1, -2 }]
 = { 11.0, 10.0, 16.0, 15.0 } (double[4])
da7[{ -6 :  5 }]  !! -> da7[{ -6, -5 ... -1, 0, 1 ... 4, 5 }]
 = { 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 } (double[12])

da7[  5 :  1 ]  ! reverse order
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[  5 : -6 ]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[ -2 :  1 ]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[ -2 : -6 ]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[{  5 :  1 }]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[{ -2 : -6}]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
da7[{ -2 :  1 }]  !! -> da7[{ -2, -1, 0, 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (double[4])
da7[{ -2, -1, 0, 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (double[4])
da7[{  5 : -6 }]  !! -> da7[{ 5, 4 ... 1, 0, -1 ... -5, -6 }]
 = { 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0 } (double[12])

al7[ 1 : 5 ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (java.lang.Double[5])
al7.get { 1 : 5 }
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (java.lang.Double[5])
al7[ -2 : 1 ]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (java.lang.Double[5])
al7[{ -2 : 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (java.lang.Double[4])
al7[{ -2, -1, 0, 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (java.lang.Double[4])
$this.test "al7.get { -2 : 1 }"  ! negative indices not allowed for ArrayList.get(int)
: al7.get { -2 : 1 }
?                 ^
? java.util.ArrayList.get( int[4] ): java.lang.ArrayIndexOutOfBoundsException: -2
 = KmgFormelException: java.util.ArrayList.get( int[4] ): java.lang.ArrayIndexOutOfBoundsException: -2 (KmgFormelException)

ra7[ 1 : 5 ]
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
ra7. get { 1 : 5 }
 = { 11.0, 12.0, 13.0, 14.0, 15.0 } (double[5])
ra7[ -2 : 1 ]
 = { 15.0, 14.0, 13.0, 12.0, 11.0 } (double[5])
ra7[{ -2 : 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (double[4])
ra7[{ -2, -1, 0, 1 }]
 = { 15.0, 16.0, 10.0, 11.0 } (double[4])
$this.test "ra7.get { -2 : 1 }"  ! negative indices not allowed for JxnRealArrayAlgebra.get(int)
: ra7.get { -2 : 1 }
?                 ^
? JxnRealArrayAlgebra.get( int[4] ): java.lang.ArrayIndexOutOfBoundsException: -2
 = KmgFormelException: JxnRealArrayAlgebra.get( int[4] ): java.lang.ArrayIndexOutOfBoundsException: -2 (KmgFormelException)

ra7[ 0.5 + { 1 : 5 } ]  ! JxnRealArrayAlgebra.get(double) interpolates
 = { 11.5, 12.5, 13.5, 14.5, 15.5 } (double[5])
ra7[{ 1.5, 2.5, 3.5, 4.5, 5.5 }]
 = { 11.5, 12.5, 13.5, 14.5, 15.5 } (double[5])
ra7[ 0.5 + { 5 : 1 } ]
 = { 15.5, 14.5, 13.5, 12.5, 11.5 } (double[5])
ra7.get( 0.5 + { 5 : 1 } )
 = { 15.5, 14.5, 13.5, 12.5, 11.5 } (double[5])