Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 26, 2010 [Issue 4729] New: std.algorithm: atrange iota behaviour | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4729 Summary: std.algorithm: atrange iota behaviour Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Optlink AssignedTo: nobody@puremagic.com ReportedBy: necroment@gmail.com --- Comment #0 from Max Klyga <necroment@gmail.com> 2010-08-26 05:16:40 PDT --- import std.stdio, std.algorithm, std.range; void main() { filter!((int n) { write(n, ' '); return 0; })(iota(1, 10)); //writes: 1 2 3 4 5 6 7 8 9 writeln(); reduce!"0"( filter!((int n) { write(n, ' '); return 1; })(iota(1, 10)) ); //writes: 1 2 3 4 5 6 7 8 9 writeln(); reduce!"0"( filter!((int n) { write(n, ' '); return 0; })(iota(1, 10)) ); //Never stops writing numbers } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 26, 2010 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc Summary|std.algorithm: atrange iota |std.algorithm: strange iota |behaviour |behaviour --- Comment #1 from bearophile_hugs@eml.cc 2010-08-26 06:04:08 PDT --- It seems a iota() problem. import std.algorithm: reduce, filter; import std.range: iota; void main() { reduce!"0"(filter!((int a){ return false; })(iota(1))); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 26, 2010 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 --- Comment #2 from Max Klyga <necroment@gmail.com> 2010-08-26 07:50:27 PDT --- This bug was introduced in 2.048, as is 2.047 iota stops but fails shortly after: src/phobos/std/algorithm.d(279): Enforcement failed -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 09, 2011 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |andrei@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 01, 2012 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 Brad Anderson <eco@gnuk.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eco@gnuk.net --- Comment #3 from Brad Anderson <eco@gnuk.net> 2012-02-01 13:21:38 PST --- 2.057 seems to handle this situation (trying to reduce an empty range but not offering a seed) by throwing an appropriate exception: object.Exception@C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(662): Cannot reduce an empty range w/o an explicit seed value. I believe this should be closed. Also, not sure why this is set as an optlink issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 04, 2013 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx --- Comment #4 from hsteoh@quickfur.ath.cx 2013-01-03 20:24:38 PST --- In latest git head, throws an exception. Is this acceptable (should the bug be closed)? Or is it better to have reduce return (ElementType!R).init? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 --- Comment #5 from bearophile_hugs@eml.cc 2013-01-04 17:53:04 PST --- (In reply to comment #4) > In latest git head, throws an exception. Is this acceptable (should the bug be > closed)? > > Or is it better to have reduce return (ElementType!R).init? The reduce of Python returns the start value: >>> reduce(lambda a,b: a * b, [], 0) 0 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 --- Comment #6 from hsteoh@quickfur.ath.cx 2013-01-04 18:17:16 PST --- The problem here is that no start value is given. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 --- Comment #7 from bearophile_hugs@eml.cc 2013-01-04 18:36:53 PST --- (In reply to comment #6) > The problem here is that no start value is given. In this case Python raises an error. I think this is acceptable: >>> reduce(lambda a,b: a * b, []) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: reduce() of empty sequence with no initial value -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 05, 2013 [Issue 4729] std.algorithm: strange iota behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Klyga | http://d.puremagic.com/issues/show_bug.cgi?id=4729 --- Comment #8 from hsteoh@quickfur.ath.cx 2013-01-04 22:11:08 PST --- In that case, we should probably close the bug, since the latest Phobos throws an exception upon calling reduce() with an empty range and no start value. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation