Skip to content

Instantly share code, notes, and snippets.

@jmgrosen
Last active December 20, 2015 08:29
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 jmgrosen/6100505 to your computer and use it in GitHub Desktop.
Save jmgrosen/6100505 to your computer and use it in GitHub Desktop.
use std::os;
fn tokenize(raw: &str) -> ~[&str] {
let replaced: ~str = raw.replace("(", " ( ").replace(")", " ) ");
replaced.split_iter(' ').collect()
}
fn main() {
printfln!("%?", tokenize(os::args()[1]));
}
use std::os;
fn tokenize(raw: &str) -> ~[~str] {
let replaced: ~str = raw.replace("(", " ( ").replace(")", " ) ");
replaced.split_iter(' ').transform(|token| token.to_owned()).collect()
}
fn main() {
printfln!("%?", tokenize(os::args()[1]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment