Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
isPalindrome := [:aString |
|
||||
str := (aString select: [:chr| chr isAlphaNumeric]) collect: [:chr | chr asLowercase].
|
||||
str = str reversed.
|
||||
].
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
String extend [
|
||||
palindro [ "Non-recursive"
|
||||
^ self = (self reverse)
|
||||
]
|
||||
palindroR [ "Recursive"
|
||||
(self size) <= 1 ifTrue: [ ^true ]
|
||||
ifFalse: [ |o i f| o := self asOrderedCollection.
|
||||
i := o removeFirst.
|
||||
f := o removeLast.
|
||||
i = f ifTrue: [ ^ (o asString) palindroR ]
|
||||
ifFalse: [ ^false ]
|
||||
]
|
||||
]
|
||||
].
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
('hello' palindro) printNl.
|
||||
('hello' palindroR) printNl.
|
||||
('ingirumimusnocteetconsumimurigni' palindro) printNl.
|
||||
('ingirumimusnocteetconsumimurigni' palindroR) printNl.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SequenceableCollection>>isPalindrome
|
||||
^self reverse = self
|
||||
Loading…
Add table
Add a link
Reference in a new issue