 !    ] if ; inline
 
 : scale-chunks ( chunks xwidth xmin,xmax yheight ymin,ymax -- chunks' )
-    scale-mapper [ scale-mapper ] dip swap
-    '[ [ first2 @ swap @ swap 2array ] map ] map ;
+    [ scale-mapper ] 2bi@ '[ [ _ _ bi* ] assoc-map ] map ;
 
 PRIVATE>
 
 : draw-line ( seq -- )
-    dup [ 1 head-slice* ] over length odd? [ dip ] [ call ] if
-    1 tail-slice append
+    dup [ but-last-slice ] over length odd? [ dip ] [ call ] if
+    rest-slice append
     [ (line-vertices) gl-vertex-pointer GL_LINES 0 ] keep
     length glDrawArrays ;
 

    ] if ;

: first-point ( chunks -- first-point ) first first ;
: last-point ( chunks -- last-point ) last last ;

SYMBOL: elt

: each2* ( seq quot: ( prev next -- next' ) -- last )
    [ unclip-slice elt ] dip '[
        [ elt get swap @ elt set ] each elt get
    ] with-variable ; inline

:: (make-pair) ( prev next min max -- next' )
    prev next min max

: search-first? ( elt seq -- index elt exact-match? )
    dupd search-first rot [ dup first ] dip = ;

! Return a slice of the seq with all elements equal elt to the
! left of the index, plus one that's not equal, if requested.
:: adjusted-tail-slice ( n elt plus-one? seq -- slice )
    n seq elt first '[ first _ = not ] find-last-from drop seq swap
    [ plus-one? [ 1 + ] unless tail-slice ] when* ;

! Return a slice of the seq with all elements equal elt to the
! right of the index, plus one that's not equal, if requested.
:: adjusted-head-slice ( n elt plus-one? seq -- slice )
    n seq elt first '[ first _ = not ] find-from drop seq swap
    [ plus-one? [ 1 + ] when short head-slice ] when* ;

! : data-rect ( data -- rect )
