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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
defmodule Counter do
def run do
count = 0
is_dark = false
update_ui = fn ->
IO.puts("Counter: #{count}")
IO.puts("Theme: #{if is_dark, do: \"Dark\", else: \"Light\"}")
end
increment = fn ->
count = count + 1
update_ui.()
end
decrement = fn ->
count = count - 1
update_ui.()
end
reset = fn ->
count = 0
update_ui.()
end
toggle_theme = fn ->
is_dark = !is_dark
update_ui.()
end
# Simulate actions
update_ui.()
increment.()
increment.()
toggle_theme.()
decrement.()
reset.()
end
end
Counter.run()Coding works best on desktop or with an external keyboard.