-- Solutions to exercises from the Central European Functional Programming summer school -- July 4th-16th 2005 -- Write a Hume program to implement an or-gate; -- HW-Hume solution -- Note -- a) the use of boxes to generate test inputs/outputs; -- b) the deliberate stopping of testb1 using (*,*); and -- c) the automatic conversion from Bit to string in the output of "or" -- Kevin Hammond, 5th July 2005 program type Bit = int 1; box testb1 in (n :: int 32) out (n' :: int 32, b :: Bit) match n -> if n > 3 then (*,*) else (n+1,if n < 2 then 0 else 1); box testb2 in (b :: Bit) out (b1, b2 :: Bit) match 0 -> (1,1) | 1 -> (0,0); box or in (b1,b2::Bit) out (s::Bit) match (0,0) -> 0 | (_,_) -> 1; stream stdout to "std_err"; wire testb1 (testb1.n') (testb1.n initially 0,or.b1); wire testb2 (testb2.b1) (testb2.b initially 1,or.b2); wire or (testb1.b,testb2.b2) (stdout);