-1

Why do we have functions that reverse strings and why would you want to reverse it? In what situations would you use it?

Thank you

4
  • 2
    @atornblad Looks more like "bored at work" to me :D
    – bezmax
    Dec 9, 2011 at 8:00
  • I have to admit, though, that I have never used String#reverse. While on the other hand, we miss things like Arrays#contains in Java.
    – Thilo
    Dec 9, 2011 at 8:01
  • 1
    It could be homework if you want it to be. What is the point of stack overflow if questions you ask just get closed and you get stupid useless comments. Try searching why do we have string reverse and you will not find anything. I need to visualize things, that is why I am asking. I don't know much about programming so understanding why and in what situations you do it is important.
    – beacon
    Dec 9, 2011 at 15:42
  • Reversing (not just strings but sequences in general) turns out to be a very basic tool box item. The question is like asking why you would want to have a spanner in your tool box. It'll make a lot more sense once you're introduced to bolts and nuts. In the mean time however, this is a "make a list" question which should probably have been closed as "not constructive" rather than "not real", but should definitely have been closed. Dec 10, 2011 at 0:28

1 Answer 1

5

To find words that rhymes. To enable indexing when searching with a wildcard in front of a word. The letters in the string might represent items in a queue that needs to be reversed. Some search and replace operations are easier if the string is reversed first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.