Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
:- module counter.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
Count = 0,
IsDark = no,
updateUI(Count, IsDark, !IO),
Count1 = Count + 1,
updateUI(Count1, IsDark, !IO),
Count2 = Count1 + 1,
updateUI(Count2, IsDark, !IO),
IsDark1 = yes,
updateUI(Count2, IsDark1, !IO),
Count3 = Count2 - 1,
updateUI(Count3, IsDark1, !IO),
Count4 = 0,
updateUI(Count4, IsDark1, !IO).
:- pred updateUI(int::in, bool::in, io::di, io::uo) is det.
updateUI(Count, IsDark, !IO) :-
io.write_string("Counter: "), io.write_int(Count), io.write_string("\n", !IO),
(io.write_string("Theme: Dark\n", !IO) :- IsDark ; io.write_string("Theme: Light\n", !IO)).Coding works best on desktop or with an external keyboard.