------------------------------------------------------------------------------ -- 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