Reverse String

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

Inputs

string - A string

Outputs

The reversal of the input string, or an empty string if the input is not a string.

Variables Used

s, temp, i
All are created locally in the program.

Calculator Compatibility

TI-89/92/+/V200

:reverse(s)
:Func
:Local i,temp
:""→temp
:If getType(s)=getType(temp) Then
: For i,1,dim(s)
:  mid(s,i,1)&temp→temp
: EndFor
:EndIf
:EndFunc

This function requires the user to enter a string as an argument. Many would object that a "return" is needed at the end. This is not true, because, if there is no "return" statement, the calculator automatically returns the last value that it calculated.

Error Conditions

None

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.