Menu: Difference between revisions

Content added Content deleted
 
Line 1,830: Line 1,830:
<syntaxhighlight lang="langur">val .select = impure fn(.entries) {
<syntaxhighlight lang="langur">val .select = impure fn(.entries) {
if .entries is not list: throw "invalid args"
if .entries is not list: throw "invalid args"
if len(.entries) == 0: return ""
if not .entries: return ""


# print the menu
# print the menu
writeln join "\n", map(fn(.e, .i) { $"\.i:2;: \.e;" }, .entries, 1..len .entries)
writeln join "\n", map(fn .e, .i: "{{.i:2}}: {{.e}}", .entries, 1..len .entries)


val .idx = number read(
val .idx = number read(
Line 1,848: Line 1,848:
}
}


writeln .select(["fee fie", "eat pi", "huff and puff", "tick tock"])</syntaxhighlight>
writeln .select(["fee fie", "eat pi", "huff and puff", "tick tock"])
</syntaxhighlight>


{{out}}
{{out}}