Anonymous user
Search a list: Difference between revisions
→{{header|SenseTalk}}
Drkameleon (talk | contribs) No edit summary |
|||
Line 3,472:
7
</pre>
=={{header|SenseTalk}}==
<lang sensetalk>
put ("apple", "banana", "cranberry" ,"durian", "eggplant", "grape", "banana", "appl", "blackberry") into fruitList
put findInList(fruitList,"banana")
put findInList(fruitList,"banana", true)
put findInList(fruitList,"tomato")
function findInList paramList, paramItem, findLast
set temp to every offset of paramItem within paramList
if (number of items in temp = 0)
Throw InvalidSearch, "Item not found in list"
end if
if findLast
return last item of temp
else
return first item of temp
end if
end findInList
</lang>
Note: Sensetalk indexes from 1
=={{header|Sidef}}==
|