D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4802 - Incorrect Radial example
Summary: Incorrect Radial example
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-03 08:50 UTC by Andrej Mitrovic
Modified: 2010-09-03 16:29 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 Andrej Mitrovic 2010-09-03 08:50:34 UTC
From: http://www.digitalmars.com/d/2.0/phobos/std_range.html#Radial

int[] a = [ 1, 2, 3, 4, 5 ];
assert(equal(radial(a) == [ 3, 2, 4, 1, 5 ][]));
a = [ 1, 2, 3, 4 ];
assert(equal(radial(a) == [ 2, 3, 1, 4 ][]));

The equality Op shouldn't be there but the first array literal is wrong as well. This should be:

int[] a = [ 1, 2, 3, 4, 5 ];
assert(equal(radial(a), [ 3, 4, 2, 5, 1 ]));
a = [ 1, 2, 3, 4 ];
assert(equal(radial(a), [ 2, 3, 1, 4 ]));
Comment 1 Andrej Mitrovic 2010-09-03 08:52:42 UTC
The docs also state:

Iterates a random-access range starting from a given point and progressively extending left and right from that point. If no initial point is given, iteration starts from the middle of the range. Iteration spans the entire range. 

However it iterates Right first and then Left, not the other way around. So maybe change the sentence to: "Iterates a random-access range starting from a given point and progressively extending right and left from that point."