Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Curry (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===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: x ? y = x x ? y = y Thus, the evaluation of the expression {{Mono|0 ? 1}} returns {{Mono|0}} as well as {{Mono|1}}. Computing with non-deterministic operations and computing with free variables by narrowing has the same expressive power.<ref>{{cite book |last1=Sergio |first1=Antoy |last2=Hanus |first2=Michael |title=Logic Programming |chapter=Overlapping Rules and Logic Variables in Functional Logic Programs |series=Lecture Notes in Computer Science |year=2006 |doi=10.1007/11799573_9 |volume=4079 |pages=87β101 |isbn=978-3-540-36635-5}}</ref> The rules defining {{Mono|?}} show an important feature of Curry: all rules are tried in order to evaluate some operation. Hence, one can define by <syntaxhighlight lang="haskell"> insert x ys = x : ys insert x (y:ys) = y : insert x ys </syntaxhighlight> an operation to insert an element into a list at an indeterminate position so that the operation {{Mono|perm}} defined by <syntaxhighlight lang="haskell"> perm [] = [] perm (x:xs) = insert x (perm xs) </syntaxhighlight> returns any permutation of a given input list.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)