Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,15 @@
| haystack |
haystack := 'Zig,Zag,Wally,Ronald,Bush,Krusty,Charlie,Bush,Bozo' subStrings: $,.
{ 'Washington' . 'Bush' } do: [:word |
|t|
((t := haystack indexOf: word) = 0)
ifTrue: [ ('%1 is not in the haystack' % { word }) displayNl ]
ifFalse: [
|l|
('%1 is at index %2' % { word . t }) displayNl.
l := ( (haystack size) - (haystack reverse indexOf: word) + 1 ).
( t = l ) ifFalse: [
('last occurence of %1 is at index %2' % { word . l }) displayNl ]
]
].

View file

@ -0,0 +1,22 @@
| haystack |
haystack := 'Zig,Zag,Wally,Ronald,Bush,Krusty,Charlie,Bush,Bozo' subStrings: $,.
[
{ 'Washington' . 'Bush' . 'Ronald' } do: [:word |
|firstIdx lastIdx|
firstIdx := haystack
indexOf:word
ifAbsent:[
ProceedableError raiseRequestWith:word errorString:'not found'.
0
].
firstIdx = 0 ifFalse:[
(lastIdx := haystack lastIndexOf:word) = firstIdx
ifTrue:[ e'the first index of {word} is {firstIdx}' printCR ]
ifFalse:[ e'the last index of {word} is {lastIdx}' printCR ]]
]
] on:Error do:[:ex |
e'{ex description} exception raised for: {ex parameter}' printCR.
'but I don''t care and proceed...' printCR.
ex proceed.
]