Smap
SmapIE
New program
Curry
Prolog
Haskell
Open program by ID
Browser
Dashboard
Programs on Smap
Most recent
Most favorited
Tags on Smap
All tags
Sign in
Help
Source code
Language:
Curry
------------------------------------------------------------------------------ -- Example for the extension of Curry with functional patterns as described in: -- -- Sergio Antoy, Michael Hanus: -- Declarative Programming with Function Patterns -- Proceedings of the International Symposium on Logic-based Program Synthesis -- and Transformation (LOPSTR'05), Springer LNCS 3901, pp. 6-22 ------------------------------------------------------------------------------ -- define an operation to compute the last element of a list -- by a functional pattern: last :: [a] -> a last (_++[x]) = x -- Example goal (showing the list elements are not evaluated): goal1 = last [1,2,failed,3,4] -- define a palindrome constraint using functional patterns: pali :: [a] -> Success pali (xs ++ reverse xs) = success pali (xs ++ _:reverse xs) = success -- Example goal: goal2 = pali "otto" main = goal1
Execution result
No execution result yet.
PAKCS 3.7 /all-values
PAKCS 3.7 /one-value
KiCS2 3.1 /all-values
KiCS2 3.1 /one-value
Reset
Clear
Options
New Curry program
Reload program 5
View in Browser
Program ID:
5
Title:
Functional Patterns: last, palindrome
Language:
Curry
Author:
mh
Version:
1
Program information