#   p o i n t - i n d e x 
 
 
 
 a   p o i n t   l i b r a r y   f o r   w o r k i n g   w i t h   2 d   a r r a y s   o r   v e c t o r s . 
 
 
 
 i t   h a s   a l l   t h e   c a r d i n a l   d i r e c t i o n   f o r   p o i n t   a d d i t i o n   a s   w e l l   a s   s c a l a r   m u l t i p l i c a t i o n . 
 
 # #   E x a m p l e s 
 
 h e r e   a r e   a   c o u p l e   o f   e x a m p l e s   o f   a r r a y   a c c e s s i n g 
 
 ` ` ` r u s t 
 
 u s e   p o i n t _ i n d e x : : * ; 
 
 l e t   m u t   v e c   =   v e c ! [ v e c ! [ 0 ,   1 ,   2 ] ,   v e c ! [ 3 ,   4 ,   5 ] ,   v e c ! [ 6 ,   7 ,   8 ] ] ; 
 
 l e t   m u t   p o i n t 1   =   P o i n t   {   x :   1 ,   y :   1   } ; 
 
 a s s e r t _ e q ! ( v e c [ p o i n t 1 ] ,   4 ) ; 
 
 / /   U p   i s   t h e   s a m e   a s   P o i n t   { x :   0 ,   y :   - 1 } 
 
 l e t   p o i n t 2   =   p o i n t 1   +   U P ; 
 
 a s s e r t _ e q ! ( v e c [ p o i n t 2 ] ,   1 ) ; 
 
 / /   D o w n   i s   t h e   s a m e   a s   P o i n t   { x :   0 ,   y :   1 } 
 
 l e t   p o i n t 3   =   p o i n t 2   +   D O W N   *   2 ; 
 
 a s s e r t _ e q ! ( v e c [ p o i n t 3 ] ,   7 ) ; 
 
 / /   U p   l e f t   i s   t h e   s a m e   a s   P o i n t   { x :   - 1 ,   y :   - 1 } 
 
 l e t   p o i n t 4   =   p o i n t 1   +   U P _ L E F T ; 
 
 a s s e r t _ e q ! ( v e c [ p o i n t 4 ] ,   0 ) 
 
 ` ` ` 
 
 h e r e   i s   a   s a m p l e   o f   e x a m p l e s   o f   a r r a y   m u t a t i o n 
 
 ` ` ` r u s t 
 
 u s e   p o i n t _ i n d e x : : * ; 
 
 l e t   m u t   a r r   =   [ [ 0 ;   1 0 ] ;   1 0 ] ; 
 
 / /   d o w n   r i g h t   i s   t h e   s a m e   a s   P o i n t   { x :   1 ,   y :   1 } 
 
 f o r   x   i n   0   . .   1 0 { 
 
         a r r [ D O W N _ R I G H T   *   x ]   =   x 
 
 } 
 
 a s s e r t _ e q ! ( 
 
         a r r , 
 
       [ [ 0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   1 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   2 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   3 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   4 ,   0 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   0 ,   5 ,   0 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   6 ,   0 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   7 ,   0 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   8 ,   0 ] , 
 
         [ 0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   0 ,   9 ] ] 
 
 
 
 ) 
 
 ` ` ` 
 
 
 
 L i c e n s e :   M I T   O R   A p a c h e - 2 . 0 
 
 