Task[edit]
Find the index of a string (needle) in an indexable, ordered collection of strings (haystack).

Raise an exception if the needle is missing.

If there is more than one occurrence then return the smallest index to the needle.

Extra credit
Return the largest index to a needle that has multiple occurrences in the haystack.

See also
 Search a list of records

"mouse" "hat" "cup" "deodorant" "television"
"soap" "methamphetamine" "severed cat heads" "cup"
pstack
stklen tolist reverse
0 tolist var t
 
"Enter string to search: " input var s nl
true
while
    head s == if
        len t swap 0 put var t
    endif
    tail nip len
endwhile
drop
 
t len not if
    "String not found in list" print
else
    reverse
    "First index for " print s print " : " print 1 get print
    len 1 > if
        nl "Last index for " print s print " : " print len get print
    endif
endif
drop