RosettaCodeData/Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st
2023-07-01 13:44:08 -04:00

14 lines
394 B
Smalltalk

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 ]
]
]
].