2022-06-28 11:25:43 +03:00
|
|
|
module Input;
|
|
|
|
|
|
|
|
open import Prelude;
|
|
|
|
|
|
|
|
odd : Nat → Bool;
|
|
|
|
|
|
|
|
even : Nat → Bool;
|
|
|
|
|
|
|
|
odd zero ≔ false;
|
|
|
|
odd (suc n) ≔ even n;
|
|
|
|
|
|
|
|
even zero ≔ true;
|
|
|
|
even (suc n) ≔ odd n;
|
|
|
|
|
|
|
|
check : (Nat → Bool) → Int → String;
|
2022-07-25 13:30:18 +03:00
|
|
|
check f x ≔ boolToStr (f (intToNat x));
|
2022-06-28 11:25:43 +03:00
|
|
|
|
|
|
|
checkEven : Int → String;
|
|
|
|
checkEven ≔ check even;
|
|
|
|
|
|
|
|
checkOdd : Int → String;
|
|
|
|
checkOdd ≔ check odd;
|
|
|
|
|
|
|
|
main : Action;
|
|
|
|
main ≔ put-str "even 1: " >> put-str-ln (checkEven 1)
|
|
|
|
>> put-str "even 4: " >> put-str-ln (checkEven 4)
|
|
|
|
>> put-str "even 9: " >> put-str-ln (checkEven 9)
|
|
|
|
>> put-str "odd 1: " >> put-str-ln (checkOdd 1)
|
|
|
|
>> put-str "odd 4: " >> put-str-ln (checkOdd 4)
|
|
|
|
>> put-str "odd 9: " >> put-str-ln (checkOdd 9)
|
|
|
|
|
|
|
|
end;
|