Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Menu/Prolog/menu-1.pro
Normal file
17
Task/Menu/Prolog/menu-1.pro
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
rosetta_menu([], "") :- !. %% Incase of an empty list.
|
||||
rosetta_menu(Items, SelectedItem) :-
|
||||
repeat, %% Repeat until everything that follows is true.
|
||||
display_menu(Items), %% IO
|
||||
get_choice(Choice), %% IO
|
||||
number(Choice), %% True if Choice is a number.
|
||||
nth1(Choice, Items, SelectedItem), %% True if SelectedItem is the 1-based nth member of Items, (fails if Choice is out of range)
|
||||
!.
|
||||
|
||||
display_menu(Items) :-
|
||||
nl,
|
||||
foreach( nth1(Index, Items, Item),
|
||||
format('~w) ~s~n', [Index, Item]) ).
|
||||
|
||||
get_choice(Choice) :-
|
||||
prompt1('Select a menu item by number:'),
|
||||
read(Choice).
|
||||
Loading…
Add table
Add a link
Reference in a new issue