2 USING: kernel arrays sequences math.vectors mortar slot-accessors ;
8 <pos> { "pos" } accessors define-independent-class
12 "x" !( pos -- x ) [ $pos first ]
14 "y" !( pos -- y ) [ $pos second ]
16 "set-x" !( pos x -- pos ) [ 0 pick $pos set-nth ]
18 "set-y" !( pos y -- pos ) [ 1 pick $pos set-nth ]
20 "distance" !( pos pos -- distance ) [ $pos swap $pos v- norm ]
22 "move-by" !( pos offset -- pos ) [ over $pos v+ >>pos ]
24 "move-by-x" !( pos x-offset -- pos ) [ 0 2array <-- move-by ]
26 "move-by-y" !( pos y-offset -- pos ) [ 0 swap 2array <-- move-by ]