ID:172781
Mar 27 2004, 10:37 pm (Edited on Mar 27 2004, 10:43 pm)
|
|
Seemed simple at first, but I've tried many times to create a proc that would take a text string, flip it around (IE, "Hello BYOND!" would end up "!DNOYB olleH") and then display it however I choose, but I've failed miserably many times and my coding is so messed up that I'm not even gonna post it. Could anyone educate me on how to perform this?
|
In response to Lazyboy
|
|
Eeek. No need to use lists! =)
A much simpler and faster version: <code>proc/reversetext(txt as text) var/reversed="" for (var/X=length(txt); X>=1; X--) reversed+=copytext(txt,X,X+1) return reversed</code> |
In response to Crispy
|
|
Crispy wrote:
Eeek. No need to use lists! =) Too much c++ for me i think. Plus its been a long day and i couldnt be bothered thinking too much. |
In response to Crispy
|
|
Now, I hate to bother, but I see the code, I know it works, but I haven't the faintest idea why. Most specifically, that for() statement. Mind explaining it?
|
I have just been toying around with this, and i havent really checked this, but this is what i came up with (i know its very unoptimised, but i just threw this together)