anchor.diff:  (define (totalize the-data (number-of-days 30) (start-at 0))
     ; add the last number-of-days days of data  
     ; most recent first
  -  (sort the-data >)
  +  
     (set 'data-slice (slice the-data start-at number-of-days))
  -  ; (("2011 02 10" (456 1356)) ("2011 02 09" (852 1951)) ("2011 02 08" (703 2361)) ("2011 02 07" 
  -  ;  (1251 2223))  ("2011 02 06" (776 776)) 
  -        (list 
  -           (apply + (map (fn (f)  (first (last f))) data-slice))
  -           (apply + (map (fn (f)  (last  (last f))) data-slice))))
  +        (list (apply + (map (fn (f)  (first (last f))) data-slice))
  +              (apply + (map (fn (f)  (last  (last f))) data-slice))))
   
  -; get lines of data from router
  +; get data from router
   (set 'raw-data (get-traffic-data "DD-WRT" "root" "13142"))
  -(set 'data-table '())
  -(map (fn (a) (extend data-table (add-data a))) raw-data)
  +;-> ("traff-03-2011=859:778 555:1526 1974:1273 1901:366 1230:546 831:303 499:383 394:278 1421:430 492:434 1531:439 1275:461 2407:380
   
  +; compile data into table
  +(map (fn (a) (extend data-table (add-data a))) raw-data) ; don't need to create data-table first :)
  +
  +; data-table is
  +;   (("2011 02 10" (456 1356)) 
  +;    ("2011 02 09" (852 1951)) 
  +;    ("2011 02 08" (703 2361)) etc
  +
  +; I want the total for the previous 30 days, up to i days ago, starting from today
   ; there should be at least 30 days' worth of data for this
  +
  +(sort data-table > ) ; most recent first
  +; start at today's date and select all previous (there may be blank entries for the rest of the month)
  +(set 'data-table (slice data-table (first (ref (date (date-value) 0 "%Y %m %d") data-table))))
   (set 'number-of-days 30)
  +(for (days-ago 0 30)
  +    (print "" days-ago " days ago:\t\t")
  +    (println (format {%d %d} (totalize data-table number-of-days days-ago))))
   
  -; i want the total for the previous 30 days, up to i days ago
  -(for (i 0 30)
  -    (print "" i " days ago:\t\t")
  -    (println (format {%d %d} (totalize data-table number-of-days i))))
  +; output suitable for spreadsheet
  +(map (fn (f) (println (date (parse-date (first f) {%Y %m %d})) "\t"  (first (last f)))) (sort data-table <))
   
   (exit)
positive.code: #!/usr/bin/env newlisp
  ;; @module analyse-router-traffic
  ;; @author cormullion@mac.com
  ;; @version 0.2 2011-09-06 16:41:52
  ;;
  ;; This script lets you access a DD-WRT software-based
  ;; router such as a Linksys and get the traffic data from
  
negative.code:     (set 'l (parse line "[= ]" 0))
      (set 'm-data  (pop l))
      (set 'm-data  (parse m-data "-"))
      (set 'month-number (int (m-data 1) 0 10)) ; watch out for octal
      (set 'year-number  (int (m-data 2) 0 10))
      (set 'day-number 1)
      
      (dolist (d (chop l)) ; drop last item, which are totals for month
         ; d contains a pair of numbers eg "0:23"
         (set 'incoming (first (parse d ":")))
  