Created
May 11, 2014 19:39
-
-
Save draegtun/a5b2b262adcb31e15d84 to your computer and use it in GitHub Desktop.
Reverse Words in a string - "Potential answer to SO CodeGolf challenge"
This file contains 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
Rebol [] | |
reverse-words: function [ | |
"Reverse the order of words. Modifies and returns string (series)" | |
series [string!] "At position (modified)" | |
][ | |
first-time: on | |
until [ | |
f: any [ | |
if first-time [tail series] | |
find series space | |
tail series | |
] | |
reverse/part series f | |
unless first-time [series: next f] | |
first-time: off | |
tail? series | |
] | |
head series | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment