Menu: Difference between revisions
Content added Content deleted
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) |
||
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 |
if not .entries: return "" |
||
# print the menu |
# print the menu |
||
writeln join "\n", map(fn |
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"]) |
writeln .select(["fee fie", "eat pi", "huff and puff", "tick tock"]) |
||
</syntaxhighlight> |
|||
{{out}} |
{{out}} |