Input and output modes are determined the initial goal
Metamorphosis 97
[Item1|List1]«List1occurs in the guard of two clauses. Composing guard con-straints into decision trees can eliminate redundant tests:
//partition(List,Pivot,Lesser,Greater)
part(List,Pivot,Lesser,Greater)
:- []=List
| Lesser=[] | Greater=[]
+ :- [Item|List1]=List,
{Pivot=<Item
| Greater=[Item|Greater1],
+ otherwise
| Lesser=[Item|Lesser1], part(List,Pivot,Lesser1,Greater) }.
using otherwise (or else). The otherwise clause is only tried if all others are inappli-cable.
|
---|
1980 |
---|
1981 |
|
---|