Skip to content

Instantly share code, notes, and snippets.

@draegtun
Created May 11, 2014 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draegtun/a5b2b262adcb31e15d84 to your computer and use it in GitHub Desktop.
Save draegtun/a5b2b262adcb31e15d84 to your computer and use it in GitHub Desktop.
Reverse Words in a string - "Potential answer to SO CodeGolf challenge"
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