From e6cbe8ccf80244d1e36d30ffa45dcf56d8bf982f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 18 Jun 2009 10:59:26 +0200 Subject: [PATCH] Add a higher order testcase. This testcase is taken from my report and uses some higher order constructs. --- Adders.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Adders.hs b/Adders.hs index 249bb3a..2ee1de6 100644 --- a/Adders.hs +++ b/Adders.hs @@ -146,6 +146,25 @@ rec_adder ((a:as), (b:bs)) = (rest, cin) = rec_adder (as, bs) (s, cout) = full_adder (a, b, cin) +foo = id +add, sub :: Int -> Int -> Int +add a b = a + b +sub a b = a - b + +highordtest = \x -> + let s = foo x + in + case s of + (a, b) -> + case a of + High -> add + Low -> let + op' = case b of + High -> sub + Low -> \c d -> c + in + \c d -> op' d c + -- Four bit adder, using the continous adder below -- [a] -> [b] -> ([s], cout) --con_adder_4 as bs = -- 2.30.2