Add countdown example

This commit is contained in:
Jan Van Bruggen 2022-01-22 01:00:51 -07:00
parent 0079f8f45c
commit 97149d4530
2 changed files with 19 additions and 0 deletions

View File

@ -1,2 +1,3 @@
countdown
echo echo
form form

View File

@ -0,0 +1,18 @@
app "countdown"
packages { pf: "platform" }
imports [ pf.Stdin, pf.Stdout, pf.Task.{ await, loop, succeed } ]
provides [ main ] to pf
main =
_ <- await (Stdout.line "\nLet's count down from 10 together - all you have to do is press <ENTER>.")
_ <- await Stdin.line
loop 10 tick
tick = \n ->
if n == 0 then
_ <- await (Stdout.line "🎉 SURPRISE! Happy Birthday! 🎂")
succeed (Done {})
else
_ <- await (n |> Num.toStr |> \s -> "\(s)..." |> Stdout.line)
_ <- await Stdin.line
succeed (Step (n - 1))