Tuesday, November 01, 2005

More ruby fun

Interleaving arrays together to form a super array. Kind of in reverse of what I need, but the yield comments made me thing about the idea that I could do something like

class Array
def couple()
(length-1).times { |n| yield(at(n), at(n+1)) }

Which *seems* to work, albeit throwing complaints all the way. And it does the a,b;b,c;c,d sort of thing with a list...

No comments: