Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Symbol tree-diff

837 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Symbol tree-diff

  1. 1. Before LISPs Just Part of the Past 〜 #12 symbol tree dif 〜
  2. 2. Motivation (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (defun iota (n) - (let (lst) - (dotimes (i n (nreverse lst)) - (push i lst)))) + (if (< n 0) + (error "Negative N is given : ~a." n) + (let (lst) + (dotimes (i n (nreverse lst)) + (push i lst))))) (push i lst)))) (defun iota (n) (if (< n 0) (error "Negative N is given : ~a." n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst))))) diff
  3. 3. Motivation (defun iota (n) - (let (lst) - (dotimes (i n (nreverse lst)) - (push i lst)))) + (if (< n 0) + (error "Negative N is given : ~a." n) + (let (lst) + (dotimes (i n (nreverse lst)) + (push i lst)))))
  4. 4. Motivation ● 粒度 – 行 vs 構文要素 ● 表示 – ソースコード vs 構文木 – Lispはソースコード ≒ Symbolの木
  5. 5. Symbol Tree diff (defun iota (n) (if (< n 0) (error "Negative N is given : ~a." n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst))))) (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst)))) (defun iota (n) (if (< n 0) (error "Negative N is given : ~a." n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst))))) symbol-tree-diff
  6. 6. 追加と削除 (defun foo (n) (+ n 1)) (defun foo (n) (+ n 1 2)) 追加 削除
  7. 7. 包含と抽出 包含 抽出 (eq (car lst) refmark) (if lst (eq (car lst) refmark))
  8. 8. 経路 ● 節点までの道順 – 経路 = (cons 自分の順位 親の経路) – 根の経路 = (0) nreverseの経路 : (0 2 1 2 3 0) (dotimes (i n (nreverse lst)) (push i lst)) の経路 : (2 3 0) 0
  9. 9. 経路の編集距離 ● 外部節点はEQUALか否かしか考慮しない ● 新旧にEQUALな節点がある場合、その経路の編 集距離が近い場合には追加と削除ではなく包含 や抽出と考えたほうが妥当
  10. 10. 表示 (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst)))) (defun iota (n &optional (start 0) (step 1)) (let (lst) (dotimes (i n (nreverse lst)) (push (+ (* i step) start) lst)))) (DEFUN IOTA (N &OPTIONAL (START 0) (STEP 1)) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH (+ (* I STEP) START) LST))))
  11. 11. 表示 (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst)))) (defun iota (n &optional (start 0) (step 1)) (let (lst) (dotimes (i n (nreverse lst)) (push (+ (* i step) start) lst)))) (DEFUN IOTA (N &OPTIONAL (START 0) (STEP 1)) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH I (+ (* I STEP) START) LST))))
  12. 12. 表示 (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst)))) (defun iota (n &optional (start 0) (step 1)) (let (lst) (dotimes (i n (nreverse lst)) (push (+ (* i step) start) lst)))) (DEFUN IOTA (N) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH I LST)))) (DEFUN IOTA (N &OPTIONAL (START 0) (STEP 1)) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH (+ (* I STEP) START) LST))))
  13. 13. 表示 (defun iota (n) (let (lst) (dotimes (i n (nreverse lst)) (push i lst)))) (defun iota (n &optional (start 0) (step 1)) (let (lst) (dotimes (i n (nreverse lst)) (push (+ (* i step) start) lst)))) (DEFUN IOTA (N) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH I LST)))) (DEFUN IOTA (N &OPTIONAL (START 0) (STEP 1)) (LET (LST) (DOTIMES (I N (NREVERSE LST)) (PUSH (+ (* I STEP) START) LST))))

×