Warning:
It seems that you are using Dodona within another webpage, so not everything may work properly. Let your teacher know so that he can solve the problem by adjusting a setting in the learning environment. In the meantime, you can click this link to open Dodona in a new window.
Warning:
The page was not fully loaded, probably because of a network issue. It could be that not all functionalities work as expected. Please try reloading the page.
Haskell exercise
Church getallen
Sign in to hand in your solution and get feedback.
type Church t = (t -> t) -> t -> t
-- Deze definities worden gebruikt voor de testen
zero :: Church Int
zero = \f -> \x -> x
one :: Church Int
one = \f -> \x -> f x
two :: Church Int
two = \f -> \x -> f (f x)
getNum :: Church Int -> Int
getNum church = church (+1) 0
-- Tel 1 op bij een gegeven Church getal.
increment :: Church Int -> Church Int
increment cNum = undefined
-- Zet een nummer om naar zijn Church representatie.
numToChurch :: Int -> Church Int
numToChurch num = undefined
-- Tel twee Church getallen bij elkaar op.
add :: Church Int -> Church Int -> Church Int
add cNumA cNumB = undefined
-- Vermenigvuldig twee Church getallen.
mul :: Church Int -> Church Int -> Church Int
mul cNumA cNumB = undefined