Last active
June 26, 2016 16:07
-
-
Save kulicuu/29950b28ca210f16e14a36dd268bcfa8 to your computer and use it in GitHub Desktop.
coffeescript in place string reverse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.rev = rev = (str) -> | |
| rayy = str.split '' | |
| idx = 0 | |
| jdx = rayy.length - 1 | |
| while idx < jdx | |
| cursor = rayy[idx] | |
| rayy[idx] = rayy[jdx] | |
| rayy[jdx] = cursor | |
| idx++ | |
| jdx-- | |
| return rayy.join('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment