From: Intransition Date: 2013-02-06T11:17:24+09:00 Subject: Re: How to increase flexibility of #flatten ------=_Part_2074_27631669.1360112099362 Content-Type: multipart/alternative; boundary="----=_Part_2075_12123269.1360112099362" ------=_Part_2075_12123269.1360112099362 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit First stab: def deflate(a) a.inject([]){ |c,e| (Array === e ? (Array === e.first ? c.concat(e) : c << e) : c << e); c } end Doesn't handle deeper nestings though. ------=_Part_2075_12123269.1360112099362 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit First stab:

    def deflate(a)
       a.inject([]){ |c,e| (Array === e ? (Array === e.first ? c.concat(e) : c << e) : c << e); c }
    end

Doesn't handle deeper nestings though.
------=_Part_2075_12123269.1360112099362-- ------=_Part_2074_27631669.1360112099362--