VINOTHVIJAYA / morelinq

Automatically exported from code.google.com/p/morelinq
Apache License 2.0
0 stars 0 forks source link

Review: MoreEnumerable.Lag() #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Purpose of code changes on this branch:

Rev 147: Implementation of the Lag operator, which projects a sequence by
combining each element with a prior element at a given offset. For elements
prior to the lag offset, the lagged value is considered to be default(T).
An overload exists that allows the caller to supply an alternate default
value. Lag behaves in a deferred and streaming manner.

When reviewing my code changes, please focus on:

* The public interface of the extension method.
* The effectiveness and clarity of the available XML comment documentation.
* How well this operator fits into the MoreLINQ ecosystem of
extension methods.
* The extent of coverage available from the corresponding unit tests.
* Whether edge cases are correctly identified and handled in the
implementation and tests.

After the review, I'll merge this branch into:
/trunk

Original issue reported on code.google.com by ambientl...@gmail.com on 24 Jan 2010 at 7:07

GoogleCodeExporter commented 8 years ago
Now migrated to Hg and available in clone:
http://code.google.com/r/azizatif-morelinq-evenmore/
This clone is ready to be cloned :O) for further review. It also has the 
main/default branch already merged in to bring it up to date.

Original comment by azizatif on 25 May 2012 at 11:38

GoogleCodeExporter commented 8 years ago

Original comment by azizatif on 5 Jun 2012 at 4:37

GoogleCodeExporter commented 8 years ago
Seems like the implementation is incorrect, as demonstrated here:

using System;
using System.Linq;
using MoreLinq;

static class Program {
  static void Main() {
    var lags = Enumerable.Range(1, 5);
    var nums = Enumerable.Range(0, 10);
    Console.WriteLine(
      string.Join("\n",
      from lag in lags
      select "Lag(" + lag + ")\n" 
           + string.Join("\n", nums.Lag(lag, (x, y) => new { x, y }))));
  }
}

The output is:

Lag(1)
{ x = 0, y = 0 }
{ x = 1, y = 0 }
{ x = 2, y = 1 }
{ x = 3, y = 2 }
{ x = 4, y = 3 }
{ x = 5, y = 4 }
{ x = 6, y = 5 }
{ x = 7, y = 6 }
{ x = 8, y = 7 }
{ x = 9, y = 8 }
Lag(2)
{ x = 0, y = 0 }
{ x = 1, y = 0 }
{ x = 2, y = 1 }
{ x = 3, y = 2 }
{ x = 4, y = 3 }
{ x = 5, y = 4 }
{ x = 6, y = 5 }
{ x = 7, y = 6 }
{ x = 8, y = 7 }
{ x = 9, y = 8 }
Lag(3)
{ x = 0, y = 0 }
{ x = 1, y = 0 }
{ x = 2, y = 0 }
{ x = 3, y = 2 }
{ x = 4, y = 3 }
{ x = 5, y = 4 }
{ x = 6, y = 5 }
{ x = 7, y = 6 }
{ x = 8, y = 7 }
{ x = 9, y = 8 }
Lag(4)
{ x = 0, y = 0 }
{ x = 1, y = 0 }
{ x = 2, y = 0 }
{ x = 3, y = 0 }
{ x = 4, y = 3 }
{ x = 5, y = 4 }
{ x = 6, y = 5 }
{ x = 7, y = 6 }
{ x = 8, y = 7 }
{ x = 9, y = 8 }
Lag(5)
{ x = 0, y = 0 }
{ x = 1, y = 0 }
{ x = 2, y = 0 }
{ x = 3, y = 0 }
{ x = 4, y = 0 }
{ x = 5, y = 4 }
{ x = 6, y = 5 }
{ x = 7, y = 6 }
{ x = 8, y = 7 }
{ x = 9, y = 8 }

Also posted at: https://gist.github.com/2900739

Original comment by azizatif on 9 Jun 2012 at 12:10

Attachments:

GoogleCodeExporter commented 8 years ago
Following no response from ambientlion (who possibly/assuming lost interest 
given it has taken years to get this far), taking ownership of issue to 
consider as addition for MoreLINQ 2.0 milestone.

Original comment by azizatif on 12 Jun 2013 at 10:10

GoogleCodeExporter commented 8 years ago
This issue was closed by revision ecbb044b3f86.

Original comment by azizatif on 14 Jun 2013 at 5:18