我的代码是在这里将一个字符串分解成有效的方式部分
str = "Early in his first term in office, Obama signed into law economic stimulus legislation in response"
arr= str.split(" ")
set_element= arr.each_cons(2).to_a
sub_str = set_element.map {|i| i.join(' ')}
,如果我有一个大的串像非常大的字符串,然后这个过程需要6.50秒 因为我想这种结果的
sub_str= ["Early in", "in his", "his first", "first term", "term in", "in office,", "office, Obama", "Obama signed", "signed into", "into law", "law economic", "economic stimulus", "stimulus legislation", "legislation in", "in response"]
是否有可能与任何有效的方式另辟蹊径
真棒我对此没有词 – 2013-03-22 06:16:28