Curry (programming language): Difference between revisions

Content deleted Content added
Fix link to website
m Cut needless carriage return whitespace characters in sections: standardize, aid work via small screens.
Line 43:
 
==Foundations of functional logic programming==
 
===Basic concepts===
A functional program is a set of functions defined by equations or rules. A functional computation consists of replacing subexpressions by equal (with regard to the function definitions) subexpressions until no more replacements (or reductions) are possible and a value or normal form is obtained. For instance, consider the function double defined by
Line 92 ⟶ 91:
 
===Narrowing===
 
Narrowing is a mechanism whereby a variable is [[name binding|bound]] to a value selected from among alternatives imposed by constraints. Each possible value is tried in some order, with the remainder of the program invoked in each case to determine the validity of the binding. Narrowing is an extension of logic programming, in that it performs a similar search, but can actually generate values as part of the search rather than just being limited to testing them.
 
Line 112 ⟶ 110:
 
===Functional patterns===
 
The rule defining {{Mono|last}} shown above expresses the fact that the actual argument must match the result of narrowing the expression {{Mono|ys++[e]}}. Curry can express this property also in the following more concise way:
<syntaxhighlight lang="haskell">
Line 120 ⟶ 117:
 
===Non-determinism===
 
Since Curry is able to solve equations containing function calls with unknown values, its execution mechanism is based on non-deterministic computations, similarly to logic programming. This mechanism supports also the definition of ''non-deterministic operations'', i.e., operations that delivers more than one result for a given input. The archetype of non-deterministic operations is the predefined infix operation {{Mono|?}}, called ''choice'' operator, that returns one of its arguments. This operator is defined by the following rules:
 
Line 141 ⟶ 137:
 
===Strategies===
 
Due to the absence of side effects, a functional logic program can be executed with different strategies. To evaluate expressions, Curry uses a variant of the ''needed narrowing'' strategy which combines [[lazy evaluation]] with non-deterministic search strategies. In contrast to Prolog, which uses backtracking to search for solutions, Curry does not fix a particular search strategy. Hence, there are implementations of Curry, like [http://www-ps.informatik.uni-kiel.de/kics2/ KiCS2], where the user can easily select a search strategy, like [[depth-first search]] (backtracking), [[breadth-first search]], iterative deepening, or parallel search.