/Rhino.Etl.Tests/Fibonacci/FibonacciOperation.cs

http://github.com/ayende/rhino-etl · C# · 36 lines · 31 code · 5 blank · 0 comment · 1 complexity · 186519b689a1d8e7fee85be63ab8c3ab MD5 · raw file

  1. using System.Collections.Generic;
  2. using Rhino.Etl.Core;
  3. using Rhino.Etl.Core.Operations;
  4. namespace Rhino.Etl.Tests.Fibonacci
  5. {
  6. public class FibonacciOperation : AbstractOperation
  7. {
  8. private readonly int max;
  9. public FibonacciOperation(int max)
  10. {
  11. this.max = max;
  12. }
  13. public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
  14. {
  15. int a = 0;
  16. int b = 1;
  17. var row = new Row();
  18. row["id"] = 1;
  19. yield return row;
  20. for (int i = 0; i < max - 1; i++)
  21. {
  22. int c = a + b;
  23. row = new Row();
  24. row["id"] = c;
  25. yield return row;
  26. a = b;
  27. b = c;
  28. }
  29. }
  30. }
  31. }