pabloh / lazy_enum Goto Github PK
View Code? Open in Web Editor NEWLazy Enumerable for Ruby
License: MIT License
Lazy Enumerable for Ruby
License: MIT License
Convert to lazy any ruby enumerable. Example 1: Return the square of the first 100 prime numbers greater than 1000 require 'mathn' Prime.lazy.select {|x| x > 1000 }.map {|x| x**2 }.take(100) Example 2: Find the 10001st prime. (Euler Proyect #7) Prime.lazy.drop(10000).first Example 3: Get the pytagorean triple which sum's equal to 1000. (Euler Proyect #9) dove_tailing = Enumerator.new do |yielder| Math::Naturals.each do |z| 0.step(z) do |y| 0.step(z - y) do |x| yielder << [x, y, z - y - x] end end end end dove_tailing.lazy.select {|x,y,z| (z > y && y > x) && z**2 == x**2 + y**2 }. select {|x,y,z| x + y + z == 1000 }.first Example 4: Calculate the sum of all the primes below two million. (Euler Proyect #10) Prime.lazy.take_while {|n| n < 2_000_000 }.inject(:+)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.