Hi --

On Mon, 9 Dec 2002, Martin DeMello wrote:

> require 'enum/tree'
> require 'enum/op'
>
> class << Array
>   def n_dim(*args)
>     return (1..args[0]).to_a.map! {nil} if args.length == 1
>     a = args.shift
>     (1..a).to_a.map! {n_dim(*args)}
>   end
> end
>
> class Array
>   def deep_each
>     self.by_depth { |x| x.kind_of?(Array) ? x : [] }.each {|i|
>       yield i unless i.kind_of?(Array)
>     }
>   end
> end

Couldn't you achieve the same thing with flatten?

  def deep_each
    flatten.each {|e| yield e}
  end

(I haven't used the enum tools, so there may be aspects I'm
overlooking.)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav