From: "Guy N. Hurst" Date: 2001-04-07T15:56:09+09:00 Subject: [ruby-talk:13548] #U017 "partition" method -- followup In [ruby-talk:12816] "Re: Haskell goodies, RCR and challenge", I proposed a bunch of alternate names for this, with no reply. Since the list is fairly quiet anyway, I figured I'd add some comments... First of all, the proposed feature is: (0..4).to_a.partition {|e| e%2 == 0} # => [[0,2,4], [1,3]] No one mentioned using <=> or other arbitrary methods to use instead of "==" which could result in multiple sub-arrays. I think Array#split would be a more general name for this. (String#split makes an array of substrings based on a pattern match.) Array#split would make an array of subarrays based on a block: [1,2,3,4,5].split{|x| x<=>3} # => [[3],[4,5],[1,2]] ary=["an","a","the","when","if","can","do"] ary.split{|x| x.length } # => [[],["a"],["an","if","do"],["the","can"],["when"]] Array#multiplex is another possible name. It could also be made to generate a hash, to allow for block output other than just numbers: ary.split{|x| x[0..0]} # => {"a"=>["an","a"], "t"=>["the"], etc... } Maybe Array#assort or Array#allot could be used ? Guy N. Hurst -- HurstLinks Web Development http://www.hurstlinks.com/ Norfolk, VA 23510 (757)623-9688 FAX 623-0433 PHP/MySQL - Ruby/Perl - HTML/Javascript