統一算法看似不必要的情況下 我想了解SICP here 特別描述的,在程序的統一算法「延長-IF-可能」,有一個檢查(第1名標有星號「*」),其檢查,看看是否右手「表達」是已經被綁定到的東西在當前幀中一個變量: (define (extend-if-possible var val frame)
(let ((binding (binding-in-frame var frame)))
爲什麼這項工作: power(_,0,1) :- !.
power(X,Y,Z) :-
Y1 is Y - 1,
power(X,Y1,Z1),
Z is X * Z1.
這給出了一個堆棧溢出異常? power(_,0,1) :- !.
power(X,Y,Z) :-
power(X,Y - 1,Z1),
Z is X * Z
爲什麼在C#中不允許這樣做? alt text http://img706.imageshack.us/img706/7360/restriction.png 其實我希望能寫 alias Y<A, B> : X<A, B>, X<B, A>
的統一實際上是期望在這裏;如果A = B,那麼應該定義一種方法。
我正在通過我的AI教科書工作,並且我已經來到我的部分的最後作業問題: 「以您選擇的任何語言實現第69頁的統一算法。」 在第69頁,您已經爲統一的算法如下僞代碼: function unify(E1, E2);
begin
case
both E1 and E2 are constants or the empty list:
if E1 = E2