Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,27 +0,0 @@
with ada.text_io,Ada.Strings.Unbounded; use ada.text_io, Ada.Strings.Unbounded;
procedure menu is
type menu_strings is array (positive range <>) of Unbounded_String ;
function "+" (s : string) return Unbounded_String is (To_Unbounded_String (s));
function choice (m : menu_strings; prompt : string) return string is
begin
if m'length > 0 then
loop
put_line (prompt);
for i in m'range loop
put_line (i'img &") " & To_String (m(i)));
end loop;
begin
return To_String (m(positive'value (get_line)));
exception when others => put_line ("Try again !");
end;
end loop;
end if;
return "";
end choice;
begin
put_line ("You chose " &
choice ((+"fee fie",+"huff and puff",+"mirror mirror",+"tick tock"),"Enter your choice "));
end menu;

View file

@ -1,6 +1,6 @@
menu: function [items][
selection: neg 1
while [not? in? selection 1..size items][
while [not? selection <=> 1 size items][
loop.with:'i items 'item -> print ~"|i+1|. |item|"
inp: input "Enter a number: "
if numeric? inp ->

View file

@ -1,92 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Test-Prompt-Menu.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Num-Options USAGE UNSIGNED-INT VALUE 4.
01 Example-Menu.
03 Example-Options-Data.
05 FILLER PIC X(30) VALUE "fee fie".
05 FILLER PIC X(30) VALUE "huff and puff".
05 FILLER PIC X(30) VALUE "mirror mirror".
05 FILLER PIC X(30) VALUE "tick tock".
03 Example-Options-Values REDEFINES Example-Options-Data.
05 Example-Options PIC X(30) OCCURS 4 TIMES.
01 Chosen-Option PIC X(30).
PROCEDURE DIVISION.
CALL "Prompt-Menu" USING BY CONTENT Num-Options
BY CONTENT Example-Menu
BY REFERENCE Chosen-Option
DISPLAY "You chose: " Chosen-Option
GOBACK
.
END PROGRAM Test-Prompt-Menu.
IDENTIFICATION DIVISION.
PROGRAM-ID. Prompt-Menu.
DATA DIVISION.
LOCAL-STORAGE SECTION.
01 User-Input USAGE UNSIGNED-INT.
01 Input-Flag PIC X.
88 Valid-Input VALUE "Y".
01 Options-Index USAGE UNSIGNED-INT.
01 Index-Display PIC Z(10).
LINKAGE SECTION.
01 Num-Options USAGE UNSIGNED-INT.
01 Menu-Options.
03 Options-Table PIC X(30) OCCURS 0 TO 10000000 TIMES
DEPENDING ON Num-Options.
01 Chosen-Option PIC X(30).
PROCEDURE DIVISION USING Num-Options Menu-Options Chosen-Option.
Main.
IF Num-Options = 0
MOVE SPACES TO Chosen-Option
GOBACK
END-IF
PERFORM UNTIL Valid-Input
PERFORM Display-Menu-Options
DISPLAY "Choose an option: " WITH NO ADVANCING
ACCEPT User-Input
PERFORM Validate-Input
END-PERFORM
MOVE Options-Table (User-Input) TO Chosen-Option
GOBACK
.
Display-Menu-Options.
PERFORM VARYING Options-Index FROM 1 BY 1
UNTIL Num-Options < Options-Index
MOVE Options-Index TO Index-Display
DISPLAY
Index-Display ". " Options-Table (Options-Index)
END-DISPLAY
END-PERFORM
.
Validate-Input.
IF User-Input = 0 OR > Num-Options
DISPLAY "Invalid input."
ELSE
SET Valid-Input TO TRUE
END-IF
.
END PROGRAM Prompt-Menu.

View file

@ -1,37 +0,0 @@
(let ((prompt-buffer-name "***** prompt *****")
(option-list '("fee fie"
"huff and puff"
"mirror mirror"
"tick tock"))
(extra-prompt-message "")
(is-selected nil)
(user-input-value nil))
;; Switch to an empty buffer
(switch-to-buffer-other-window prompt-buffer-name)
(read-only-mode -1)
(erase-buffer)
;; Display the options
(cl-loop for opt-idx from 1 to (length option-list) do
(insert (format "%d\) %s \n" opt-idx (nth (1- opt-idx) option-list))))
(while (not is-selected)
;; Read user input
(setq user-input-value (read-string (concat "select an option" extra-prompt-message " : ")))
(setq user-input-value (read user-input-value))
;; Validate user input
(if (and (fixnump user-input-value)
(<= user-input-value (length option-list))
(> user-input-value 0))
;; Display result
(progn
(end-of-buffer)
(insert (concat "\nYou selected: " (nth (1- user-input-value) option-list)))
(setq is-selected 't)
)
(progn
(setq extra-prompt-message " (please input a valid number)")
)
)
)
)

View file

@ -1,22 +0,0 @@
include get.e
function menu_select(sequence items, object prompt)
if length(items) = 0 then
return ""
else
for i = 1 to length(items) do
printf(1,"%d) %s\n",{i,items[i]})
end for
if atom(prompt) then
prompt = "Choice?"
end if
return items[prompt_number(prompt,{1,length(items)})]
end if
end function
constant items = {"fee fie", "huff and puff", "mirror mirror", "tick tock"}
constant prompt = "Which is from the three pigs? "
printf(1,"You chose %s.\n",{menu_select(items,prompt)})

View file

@ -9,7 +9,7 @@ end
_ok(::Any,::Any) = false
function _ok(reply::AbstractString, itemcount)
n = tryparse(Int, reply)
return isnull(n) || 0 get(n) itemcount
return isnothing(n) || 0 n itemcount
end
"Prompt to select an item from the items"
@ -20,7 +20,7 @@ function _selector(items, prompt::AbstractString)
while !_ok(reply, itemcount)
_menu(items)
print(prompt)
reply = strip(readline(STDIN))
reply = strip(readline())
end
return items[parse(Int, reply)]
end

View file

@ -1,9 +1,8 @@
val choose = fn*(entries) {
if entries is not list: throw "invalid args"
val choose = fn*(entries list) {
if not entries: return ""
# print the menu
writeln join(map(entries, 1..len(entries), by=fn e, i:"{{i:2}}: {{e}}"), by="\n")
writeln join(map(entries, 1..len(entries), by=fn e, i:"{{i:2}}: {{e}}"), delim="\n")
val idx = read(
prompt="Select entry #: ",

View file

@ -1,4 +1,5 @@
to select :prompt [:options]
if empty? :options [output []]
foreach :options [(print # ?)]
forever [
type :prompt type "| |

View file

@ -7,12 +7,12 @@ sub menu
print $prompt;
$n = <>;
return $array[$n] if $n =~ /^\d+$/ and defined $array[$n];
return &menu($prompt,@array);
return menu($prompt,@array);
}
@a = ('fee fie', 'huff and puff', 'mirror mirror', 'tick tock');
$prompt = 'Which is from the three pigs: ';
$a = &menu($prompt,@a);
$a = menu($prompt,@a);
print "You chose: $a\n";

View file

@ -1,77 +0,0 @@
function Select-TextItem
{
<#
.SYNOPSIS
Prints a textual menu formatted as an index value followed by its corresponding string for each object in the list.
.DESCRIPTION
Prints a textual menu formatted as an index value followed by its corresponding string for each object in the list;
Prompts the user to enter a number;
Returns an object corresponding to the selected index number.
.PARAMETER InputObject
An array of objects.
.PARAMETER Prompt
The menu prompt string.
.EXAMPLE
“fee fie”, “huff and puff”, “mirror mirror”, “tick tock” | Select-TextItem
.EXAMPLE
“huff and puff”, “fee fie”, “tick tock”, “mirror mirror” | Sort-Object | Select-TextItem -Prompt "Select a string"
.EXAMPLE
Select-TextItem -InputObject (Get-Process)
.EXAMPLE
(Get-Process | Where-Object {$_.Name -match "notepad"}) | Select-TextItem -Prompt "Select a Process" | Stop-Process -ErrorAction SilentlyContinue
#>
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
$InputObject,
[Parameter(Mandatory=$false)]
[string]
$Prompt = "Enter Selection"
)
Begin
{
$menuOptions = @()
}
Process
{
$menuOptions += $InputObject
}
End
{
if(!$inputObject){
return ""
}
do
{
[int]$optionNumber = 1
foreach ($option in $menuOptions)
{
Write-Host ("{0,3}: {1}" -f $optionNumber,$option)
$optionNumber++
}
Write-Host ("{0,3}: {1}" -f 0,"To cancel")
$choice = Read-Host $Prompt
$selectedValue = ""
if ($choice -gt 0 -and $choice -le $menuOptions.Count)
{
$selectedValue = $menuOptions[$choice - 1]
}
}
until ($choice -match "^[0-9]+$" -and ($choice -eq 0 -or $choice -le $menuOptions.Count))
return $selectedValue
}
}
“fee fie”, “huff and puff”, “mirror mirror”, “tick tock” | Select-TextItem -Prompt "Select a string"

View file

@ -1,21 +0,0 @@
REBOL [
Title: "Text Menu"
URL: http://rosettacode.org/wiki/Select
]
choices: ["fee fie" "huff and puff" "mirror mirror" "tick tock"]
choice: ""
valid?: func [
choices [block! list! series!]
choice
][
if error? try [choice: to-integer choice] [return false]
all [0 < choice choice <= length? choices]
]
while [not valid? choices choice][
repeat i length? choices [print [" " i ":" choices/:i]]
choice: ask "Which is from the three pigs? "
]
print ["You chose:" pick choices to-integer choice]

View file

@ -1,36 +0,0 @@
'The Function
Function Menu(ArrList, Prompt)
Select Case False 'Non-standard usage hahaha
Case IsArray(ArrList)
Menu = "" 'Empty output string for non-arrays
Exit Function
Case UBound(ArrList) >= LBound(ArrList)
Menu = "" 'Empty output string for empty arrays
Exit Function
End Select
'Display menu and prompt
Do While True
For i = LBound(ArrList) To UBound(ArrList)
WScript.StdOut.WriteLine((i + 1) & ". " & ArrList(i))
Next
WScript.StdOut.Write(Prompt)
Choice = WScript.StdIn.ReadLine
'Check if input is valid
If IsNumeric(Choice) Then 'Check for numeric-ness
If CStr(CLng(Choice)) = Choice Then 'Check for integer-ness (no decimal part)
Index = Choice - 1 'Arrays are 0-based
'Check if Index is in array
If LBound(ArrList) <= Index And Index <= UBound(ArrList) Then
Exit Do
End If
End If
End If
WScript.StdOut.WriteLine("Invalid choice.")
Loop
Menu = ArrList(Index)
End Function
'The Main Thing
Sample = Array("fee fie", "huff and puff", "mirror mirror", "tick tock")
InputText = "Which is from the three pigs: "
WScript.StdOut.WriteLine("Output: " & Menu(Sample, InputText))