Curry (programming language): Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Alter: title, template type. Add: series, chapter. Removed parameters. | Use this bot. Report bugs. | Suggested by Headbomb | #UCB_toolbar
Line 101:
last (ys++[e]) = e
</syntaxhighlight>
Haskell does not allow such a declaration since the pattern in the left-hand side contains a defined function ({{Mono|++}}). Such a pattern is also called ''functional pattern''.<ref>{{cite journalbook |last1=Sergio |first1=Antoy |last2=Hanus |first2=Michael |yeartitle=2006Logic |doi=10.1007/11680093_2Based Program Synthesis and Transformation |titlechapter=Declarative Programming with Function Patterns |journalseries=Lecture Notes in Computer Science |year=2006 |doi=10.1007/11680093_2 |volume=3901 |pages=6–22 |isbn=978-3-540-32654-0}}</ref> Functional patterns are enabled by the combined functional and logic features of Curry and support concise definitions of tasks requiring deep pattern matching in hierarchical data structures.
 
===Non-determinism===
Line 109:
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 journalbook |last1=Sergio |first1=Antoy |last2=Hanus |first2=Michael |yeartitle=2006Logic |doi=10.1007/11799573_9Programming |titlechapter=Overlapping Rules and Logic Variables in Functional Logic Programs |journalseries=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