An Introduction to Programming in Emacs Lisp Chapter 15

Chapter 15

  • insert-rectangle
    • a list of strings
    • set mark at the upper left
    • move point to the lower right
    • returns nil
  • apply
    • (apply 'max 1 3 5 '(3 8 9)) => 9
  • defvar
    • does not override
  • forward-char
    • (forward-char 3)
  • forward-line
    • (forward-line 10)
  • sit-for
    • performs redisplay
    • wait for n seconds
    • だもんで,(sit-for 1) にすると,おもしろいよね。
  • recursive-graph-body-print
    • from-position が使われていない?
    • recursive-grpah-body-print-internal にも渡してないし。。。

Exercise

以下の3つの関数の引数に optional な引数を追加してみた。
column-of-graph
rec-graph-body-print
rec-graph-body-print-internal

(defun column-of-graph (max-graph-heigh actual-height &optional line)
  (let ((insert-list nil)
        (num-of-top-blanks (- max-graph-heigh actual-height)))
    (if line
        (progn
          (while (> actual-height 1)
            (setq insert-list (cons graph-blank insert-list))
            (setq actual-height (1- actual-height)))
          (setq insert-list (cons graph-symbol insert-list)))
      (while (> actual-height 0)
        (setq insert-list (cons graph-symbol insert-list))
        (setq actual-height (1- actual-height))))
    (while (> num-of-top-blanks 0)
      (setq insert-list (cons graph-blank insert-list))
      (setq num-of-top-blanks (1- num-of-top-blanks)))
    insert-list))


(let ((graph-symbol "+"))
  (rec-graph-body-print '(1 2 3 4 6 4 3 5 7 6 5 2 3) t))
;; 以下のようになる。これであっているのだろうか?
;; bar graph の方が見やすいよなぁ。

;;         +    
;;     +    +   
;;        +  +  
;;    + +       
;;   +   +     +
;;  +         + 
;; +