Skip to content

Instantly share code, notes, and snippets.

@shaggyone
Last active December 8, 2016 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaggyone/df89b65785d8457332998c822cfccccb to your computer and use it in GitHub Desktop.
Save shaggyone/df89b65785d8457332998c822cfccccb to your computer and use it in GitHub Desktop.
a = 'a'..'z'
b = 1..1000
x = a.lazy.map { |x| puts "x-#{x}"; b.lazy.map { |y| puts "y-#{y}"; [x, y] } }.flat_map(&:itself);
y = a.lazy.map { |x| puts "y-#{x}"; b.lazy.map { |y| puts "y-#{y}"; [x, y] } }.flat_map(&:itself).take(2);
> x.select { |xx| y.include?(xx) }.any?
x-a
y-1
y-a
y-1
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment