val .select = f(.entries) { if not isArray(.entries): throw "invalid args" if len(.entries) == 0: return "" # print the menu writeln join "\n", map(f $"\.i:2;: \.e;", .entries, 1..len .entries) val .idx = toNumber read( "Select entry #: ", f(.x) { if not matching(RE/^[0-9]+$/, .x): return false val .y = toNumber .x .y > 0 and .y <= len(.entries) }, "invalid selection\n", -1, ) .entries[.idx] } writeln .select(["fee fie", "eat pi", "huff and puff", "tick tock"])