Jump to content

Search a list: Difference between revisions

(added c#)
(→‎{{header|Tcl}}: corrections)
Line 725:
=={{header|Tcl}}==
<lang tcl>set haystack {Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo}
foreach needle {Washington Bush Washington} {
if {[set idx [lsearch -exact $haystack $needle]] == -1} {
error "$needle does not appear in the haystack"
} else {
Line 734:
'''extra credit:'''
<lang tcl>set haystack {Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo}
foreach needle {Washington Bush Washington} {
set indices [lsearch -all -exact $haystack $needle]
if {[llength $indices] == 0} {
error "$needle does not appear in the haystack"
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.