diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/tasks.aup | 5 | ||||
| -rw-r--r-- | examples/words.aup | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/examples/tasks.aup b/examples/tasks.aup index 38d06ef..065f649 100644 --- a/examples/tasks.aup +++ b/examples/tasks.aup @@ -1,6 +1,8 @@ # A task list. The runtime owns the list: the index always names an item, # stays on it when items are inserted or removed before it, stops at the # ends, and a failed event leaves the list as it was. +use words + record Task { title: text done = 0 @@ -40,10 +42,11 @@ view position = at.position view current = if tasks.count > 0 { at.title } else { "(empty)" } view status = if tasks.count > 0 { "{at.position + 1}/{tasks.count}" } else { "empty" } view finished = at.done # no value while the list is empty +view summary = words.counted(tasks.count, "task", "tasks") # One row per task. A surface computes only the rows it shows. view board = each task in tasks { title = task.title - mark = if task.done { "x" } else { " " } + mark = words.check(task.done) here = task.position == at.position } diff --git a/examples/words.aup b/examples/words.aup new file mode 100644 index 0000000..2bfc0a5 --- /dev/null +++ b/examples/words.aup @@ -0,0 +1,5 @@ +# Words for counts and marks. A library: only fns, no state, so any app can +# `use words` and call words.counted(...). +fn plural(count, one, many) = if count == 1 { one } else { many } +fn counted(count, one, many) = "{count} {plural(count, one, many)}" +fn check(done) = if done { "x" } else { " " } |
