2010-03-25から1日間の記事一覧

非決定性 with 例外

『On Lisp』の非決定性が面白い。 (define (two-numbers) (list (choose '(0 1 2 3 4 5)) (choose '(0 1 2 3 4 5)))) (define (parlor-trick sum) (let ((nums (two-numbers))) (if (= (apply + nums) sum) `(the sum of ,@nums) (fail)))) > (parlor-trick …