Prolog 中的推論結構 <CLAUSE>,語法為 <PR> :- <PR>{, <PR>}.,其意義為一個推論規則,例如,Ancestor(a, c) :- Ancestor(a, b),Ancestor(b,c). 這樣一個推論語句,代表當 Ancestor(a, b) 與 Ancestor(b,c) 均為真的情況下,就可推論出 Ancestor(a, c) 必定為真。若翻譯成中文,該語句代表『若a 是 b 的祖先,且 b 是 c 的祖先,則 a 是 c 的祖先』。
void quicksort(double a[], int left, int right) {
int last = left, i;
if (left >= right) return;
swap(a,left,Random(left,right));
for (i = left + 1; i <= right; i++)
if (a[i] < a[left])
swap(a,++last,i);
swap(a,left,last);
quicksort(a,left,last-1);
quicksort(a,last+1,right);
}
void swap(double a[], int i, int j) {
double tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}