Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How I Lazy and You Can Ruby 2

How I Lazy and You Can Ruby 2

Lightning talk on Ruby's Enmuerator::Lazy

Stephen Caudill

March 12, 2014
Tweet

More Decks by Stephen Caudill

Other Decks in Programming

Transcript

  1. lazy evaluation In computer programming, lazy evaluation is the technique

    of delaying an evaluation of any expression until a value is actually being used and also avoid repeated evaluations.
  2. eager evaluation In computer programming, eager evaluation or greedy evaluation

    is the evaluation strategy used by most traditional programming languages. In eager evaluation, an expression is evaluated as soon as it is bound to a variable.
  3. fibonacci = Enumerator.new do |enum| yielder = ->(n){ enum.yield n

    } yielder.call(a=0) yielder.call(b=1) loop do a, b = b, a + b yielder.call(b) end end Combinatorics .lazy