Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Then the expression<br />
best (\x -> let y free in append x y =:= [1,2,3]) shorter<br />
computes the shortest list which can be obtained by splitting the list [1,2,3] into this list<br />
and some other list, i.e., it reduces to [\x->x=:=[]]. Similarly, the expression<br />
best (\x -> let y free in append x y =:= [1,2,3])<br />
(\l1 l2 -> length l1 > length l2)<br />
reduces to [\x->x=:=[1,2,3]].<br />
one :: (a->Success) -> [a->Success]<br />
Compute one solution via a fair strategy. If there is no solution and the search space is<br />
finite, the result is the empty list, otherwise the list contains one element (the first solution<br />
represented as a search goal).<br />
condSearch :: (a->Success) -> (a->Bool) -> [a->Success]<br />
Compute the first solution (via a fair strategy) that meets a specified condition. The condition<br />
(second argument) must be a unary Boolean function.<br />
browse :: (a->Success) -> IO ()<br />
Show the solution of a solved constraint on the standard output, i.e., a call browse g, where<br />
g is a solved search goal, is evaluated to an I/O action which prints the solution. If g is not<br />
an abstraction of a solved constraint, a call browse g produces a runtime error.<br />
browseList :: [a->Success] -> IO ()<br />
Similar to browse but shows a list of solutions on the standard output. The browse operators<br />
are useful for testing search strategies. For instance, the evaluation of the expression<br />
browseList (solveAll \x -> let y free in append x y =:= [0,1,2])<br />
produces the following result on the standard output:<br />
[]<br />
[0]<br />
[0,1]<br />
[0,1,2]<br />
Due to the laziness of the evaluation strategy, one can also browse the solutions of a goal<br />
with infinitely many solutions which are printed on the standard output until the process is<br />
stopped.<br />
8.4 Choice<br />
In order to provide a “don’t care” selection of an element out of different alternatives, which is<br />
necessary in concurrent computation structures to support many-to-one communication, <strong>Curry</strong><br />
provides the special evaluation annotation choice:<br />
f eval choice<br />
33