Created
July 8, 2014 15:36
-
-
Save sidonath/8ccfc9be312a2a5e1782 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lines = [ | |
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | |
"Sed vitae sapien dignissim, volutpat leo consectetur, iaculis magna.", | |
"In quis lacus tincidunt, vehicula ipsum in, euismod elit.", | |
"Quisque a elit in odio consequat mattis.", | |
"Fusce condimentum eros in mauris pharetra, vel accumsan mi vehicula.", | |
"Phasellus tincidunt neque eget lobortis fringilla.", | |
"In sit amet mi ut turpis dapibus commodo.", | |
"Sed non tellus non libero hendrerit iaculis.", | |
"Ut dictum dolor nec lectus cursus, at eleifend urna varius.", | |
"Phasellus congue lectus id arcu facilisis interdum.", | |
"Nunc pharetra turpis non ipsum semper, sit amet feugiat mi semper.", | |
"Nulla sit amet dui vitae odio laoreet cursus quis sed neque.", | |
"Sed eget odio in sem dignissim venenatis sed ut arcu.", | |
"Sed sit amet diam et magna sollicitudin fringilla vel pellentesque mauris.", | |
"Morbi consectetur mauris sed purus ornare, in iaculis justo bibendum.", | |
"Morbi tristique libero ut placerat posuere.", | |
"Mauris sollicitudin elit quis lobortis convallis.", | |
"In in sem sed dui pretium aliquam ac quis felis.", | |
] | |
text = Enumerator.new do |enum| | |
5.times do |i| | |
enum.yield lines[i] | |
end | |
fail "Collection came to the end" | |
end | |
out = text.lazy. | |
select { |line| line[0] == "Q" }. | |
select { |line| line.include? 'u' }. | |
flat_map { |line| line.split }. | |
select { |word| word.length > 5 }. | |
each { |word| puts word } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment