D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4456 - std.range Recurrence is horribly broken
Summary: std.range Recurrence is horribly broken
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-13 17:28 UTC by yebblies
Modified: 2010-07-13 18:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description yebblies 2010-07-13 17:28:36 UTC
Recurrence gives incorrect values when the order of previous states is important.

eg
recurrence!"a[n-1] + a[n-2]"(1,2) works, but
recurrence!"a[n-2]"(1,2) does not.

fix:

    void popFront()
    {
        _state[_n % stateSize] = binaryFun!(fun, "a", "n")(
-           cycle(_state, _n), _n + stateSize);
+           cycle(_state), _n + stateSize);
        ++_n;
    }

The old values array is being offset twice, remove the argument to cycle and it works perfectly.
Comment 1 Andrei Alexandrescu 2010-07-13 18:17:32 UTC
http://www.dsource.org/projects/phobos/changeset/1755