Created
December 13, 2018 21:53
-
-
Save philippeback/a725885d2cadfef9f55189a42012bfed to your computer and use it in GitHub Desktop.
Pharo and strings fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words := #('Peek' 'Geek' 'Coke' 'Poke' 'Meaning' 'Zapping' 'Delta' 'force' 'GEEK' 'CoKE' 'ORCa'). | |
forbiddenWords := #('ok' 'eek' 'orc'). | |
words | |
select: [ :word | | |
(forbiddenWords | |
inject: 0 | |
into: [ :sum :forbidden | | |
sum + (word | |
findString: forbidden | |
startingAt: 1 | |
caseSensitive: false ) ] ) = 0 ]. | |
words := #('Pic' 'Poc' 'Pac' 'Puc'). | |
forbidden := #('Poc' 'Puc'). | |
words reject: [ :w | forbidden includes: w ] "#('Pic' 'Pac')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment