Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
not :: Bool -> Bool<br />
not True = False<br />
not False = True<br />
-- Conditional<br />
if_then_else :: Bool -> a -> a -> a<br />
if_then_else True t _ = t<br />
if_then_else False _ f = f<br />
otherwise :: Bool<br />
otherwise = True<br />
-- Disequality<br />
(/=) :: a -> a -> Bool<br />
x /= y = not (x==y)<br />
-- Pairs<br />
data (a,b) = (a,b)<br />
fst :: (a,b) -> a<br />
fst (x,_) = x<br />
snd :: (a,b) -> b<br />
snd (_,y) = y<br />
-- Unit type<br />
data () = ()<br />
-- Lists<br />
data [a] = [] | a : [a]<br />
-- First element of a list<br />
head :: [a] -> a<br />
head (x:_) = x<br />
-- Remaining elements of a list<br />
tail :: [a] -> [a]<br />
tail (_:xs) = xs<br />
48