language: Tcl (tclsh 8.5.7)
date: 153 days 1 hour ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
set cards [list "Queen of Hearts" "3 of Clubs" "9 of Spades" \
"Ace of Hearts" "5 of Diamonds"]
# Ask user for what to search
puts -nonewline "Card for which to search (such as King, Spade, or 9): "
flush stdout
gets stdin card
# Loop until user inputs a matching card
while {[set index [lsearch $cards *[string totitle $card]*]] < 0} {
puts "No such card. Please try again."
puts -nonewline "Card for which to search (such as King, Spade, or 9): "
flush stdout gets stdin card
}
# Show the match
puts "Matched the [lindex $cards $index]"
  • upload with new input
  • result: Success     time: 0.03s    memory: 5272 kB     returned value: 0

    Card for which to search (such as King, Spade, or 9): Matched the Queen of Hearts