RosettaCodeData/Task/Palindrome-detection/Smalltalk/palindrome-detection-2.st
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07: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 ]
]
]
].