Search a list: Difference between revisions
Content added Content deleted
(→{{header|Tcl}}: corrections) |
(Slate implementation) |
||
Line 686: | Line 686: | ||
4 Bush |
4 Bush |
||
</pre> |
</pre> |
||
=={{header|Slate}}== |
|||
<lang slate> |
|||
define: #haystack -> ('Zig,Zag,Wally,Ronald,Bush,Krusty,Charlie,Bush,Bozo' splitWith: $,). |
|||
{'Washington'. 'Bush'} do: [| :needle | |
|||
(haystack indexOf: needle) |
|||
ifNil: [inform: word ; ' is not in the haystack'] |
|||
ifNotNilDo: [| :firstIndex lastIndex | |
|||
inform: word ; ' is in the haystack at index ' ; firstIndex printString. |
|||
lastIndex: (haystack lastIndexOf: word). |
|||
lastIndex isNotNil /\ (lastIndex > firstIndex) ifTrue: |
|||
[inform: 'last occurrence of ' ; word ; ' is at index ' ; lastIndex]]]. |
|||
</lang> |
|||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |