Back to notes -- Keyboard shortcut: 'u'              Slide 21 : 24
Program 1
 

(let* ((x1 50) (x2 200) (x3 350) (x4 500) (x5 650) (x6 800)
       (y0 50) (y1 100) (y2 200) (y3 350)
      )
 (with-animation '(step-buttons-reveal)
  (let*
      ((light-purple (rgb-color-encoding 255 108 255))
       (cell3-e3-disappear-step 5)
       (c1 (cons-cell x1 y1 ""))
       (c2 (cons-cell x2 y1 ""))
       (c3 (cons-cell x3 y1 "" 'step-to cell3-e3-disappear-step))  
       (c4 (cons-cell x4 y1 ""))
       (c5 (cons-cell x5 y1 ""))
       (e1 (element-node x1 y2 "e1"))
       (e2 (element-node x2 y2 "e2"))
       (e3 (element-node x3 y2 "e3" 'step-to cell3-e3-disappear-step))
       (e3-empty (svg-node rectangular x3 (- y3 50) "" 'stroke "none"))
       (e4 (element-node x4 y2 "e4"))
       (e5 (element-node x5 y2 "e5"))
        
       (e2-holdings (list  'step-from 2 'step-to 5))
       (var-tail (svg-node rectangular (+ x1 70) y0  ""
                          'bg-color "yellow" 'stroke "black"
                           e2-holdings 'min-width 40 'min-height 40 ))
       (link-from-var-tail (svg-edge var-tail "cc" c2 "lt"
                                     'stroke "black" 'arrow "yes" e2-holdings))
       (e4-holdings (list  'step-from 3 'step-to 5))
       (var-tail-1 (svg-node rectangular (+ x4 130) y0  "" 'bg-color light-purple
                             'stroke "black" e4-holdings
                             'min-width 40 'min-height 40 ))
       (link-from-var-tail-1 
           (svg-edge var-tail-1 "cc" c4 "rt" 'to-id "cdr-cell"
                     'stroke "black" 'arrow "yes" e4-holdings))
       (e1-edge (svg-edge c1 "cc" e1 "ct" 'stroke "black" 'arrow "yes"))
       (e2-edge (svg-edge c2 "cc" e2 "ct" 'stroke "black" 'arrow "yes"))
       (e3-edge (svg-edge c3 "cc" e3 "ct" 'stroke "black" 'arrow "yes" 'step-to 5)) 
       (e4-edge (svg-edge c4 "cc" e4 "ct" 'stroke "black" 'arrow "yes"))
       (e5-edge (svg-edge c5 "cc" e5 "ct" 'stroke "black" 'arrow "yes"))
       (e3-pointer 
             (svg-edge e3-empty "cc" e3 "cb" 'step-from 1 
                       'step-to cell3-e3-disappear-step
                       'stroke "red" 'stroke-width 3 'arrow "true"))
       (c-empty (svg-node rectangular x6 y1 "( )" 'stroke "none" ))
       (r1 (cons-ref c1 c2 "lc"))
       (r2 (cons-ref c2 c3 "lc" 'step-to 4))
       (r2-4 (svg-edge c2 "cc" c4 "ct" 'break-path (rv-p -50 (rh-p 260 (e-p)))
                       'step-from 4 'from-id "cdr-cell" 
                       'to-id "car-cell" 'stroke "black" 'arrow "yes"))
       (r3 (cons-ref c3 c4 "lc" 'step-to 5))
       (r4 (cons-ref c4 c5 "lc"))
       (r-ept (cons-ref c5 c-empty  "lc"))
       )
    (svg-graph 'from-step 1 'to-step 5
               (list c1 c2 c3 c4 c5 c-empty  e1 e2 e3 e4 e5   e3-empty var-tail var-tail-1)
               (list r1 r2 r3 r4 r-ept   e1-edge e2-edge e3-edge e4-edge e5-edge
                     e3-pointer link-from-var-tail link-from-var-tail-1 r2-4
                     )
               (explanations 'x 10 'y 430 'width 600 'height 100
                 'font-size 25
                 (explanation 'step 0 "The start situation. We see a list with five elements e1 ... e5.")
                 (explanation 'step 1 "We want to delete element e3 from the list.")
                 (explanation 'step 2 "In order to do so, we need a reference to the second cons cell.")
                 (explanation 'step 3 "We hold on to the fourth cons cell too.")
                 (explanation 'step 4 "We now move the cdr pointer from the second cons cell to the fourth cons cell.")
                 (explanation 'step 5 "The third element, and its accompanying cons cell disappear.")
               )         
    )
   )
  )
)