- 935 名前:934 mailto:sage [04/11/03 17:47:01]
- (define mutate
(lambda (expression) (let ((op (car expression)) (opr1 (cadr expression)) (opr2 (caddr expression)) (r (random 100))) (cond ((< r 20) (list (mutate-operator) (if (pair? opr1) (mutate opr1) opr1) (if (pair? opr2) (mutate opr2) opr2))) ((< r 60) (list op (if (pair? opr1) (mutate opr1) (mutate-operand opr1)) (if (pair? opr2) (mutate opr2) opr2))) (else (list op (if (pair? opr1) (mutate opr1) opr1) (if (pair? opr2) (mutate opr2) (mutate-operand opr2)))))))) ; (mutate (mutate (mutate (mutate '(* (+ x y) (- x y)) )))) --> (+ (* 0.8420 0.1857) (- (+ x x) 0.9704)) >20% the operator will colapse into an operand according to rule 1 これの意味は不明なのでいれてないよん。
|

|