Menu: Difference between revisions

Content added Content deleted
m (→‎Icon and Unicon: header simplification)
(added Fantom example)
Line 445: Line 445:
--- Data stack:
--- Data stack:
"fee fie"</pre>
"fee fie"</pre>

=={{header|Fantom}}==

<lang fantom>
class Main
{
static Void displayList (Str[] items)
{
items.each |Str item, Int index|
{
echo ("$index: $item")
}
}

public static Str getChoice (Str[] items)
{
selection := -1
while (selection == -1)
{
displayList (items)
Env.cur.out.print ("Select: ").flush
input := Int.fromStr(Env.cur.in.readLine, 10, false)
if (input != null)
{
if (input >= 0 && input < items.size)
{
selection = input
}
}
echo ("Try again")
}
return items[selection]
}

public static Void main ()
{
choice := getChoice (["fee fie", "huff and puff", "mirror mirror", "tick tock"])
echo ("You chose: $choice")
}
}
</lang>


=={{header|Haskell}}==
=={{header|Haskell}}==