Skip to content

Instantly share code, notes, and snippets.

@philippeback
Created December 13, 2018 21:53
Show Gist options
  • Save philippeback/a725885d2cadfef9f55189a42012bfed to your computer and use it in GitHub Desktop.
Save philippeback/a725885d2cadfef9f55189a42012bfed to your computer and use it in GitHub Desktop.
Pharo and strings fun
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