www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How to convert Map to array?

reply Sean Eskapp <eatingstaples gmail.com> writes:
I'm trying to use the array() function in std.array to convert a transformed
array using map (std.algorithm) back to a dynamic array, from a Map. I keep
getting a cryptic error "object.Exception C:\Program Files
(x86)\D\dmd2\windows\bin\..\..\src\phobos\std\
algorithm.d(426): Cannot reduce an empty range w/o an explicit seed value.".
Am I misunderstanding how this is supposed to work?
Jan 09 2011
next sibling parent Guilherme Vieira <n2.nitrogen gmail.com> writes:
--0016361e815ce70fcc0499855ee2
Content-Type: text/plain; charset=ISO-8859-1

It's easier to help if you provide sample code that produces the message. I
got that message today and fixed it, I just don't what was the problem.

-- 
Atenciosamente / Sincerely,
Guilherme ("n2liquid") Vieira


On Mon, Jan 10, 2011 at 1:25 AM, Sean Eskapp <eatingstaples gmail.com>wrote:

 I'm trying to use the array() function in std.array to convert a
 transformed
 array using map (std.algorithm) back to a dynamic array, from a Map. I keep
 getting a cryptic error "object.Exception C:\Program Files
 (x86)\D\dmd2\windows\bin\..\..\src\phobos\std\
 algorithm.d(426): Cannot reduce an empty range w/o an explicit seed
 value.".
 Am I misunderstanding how this is supposed to work?

--0016361e815ce70fcc0499855ee2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div>It&#39;s easier to help if you provide sample code that produces the m= essage. I got that message today and fixed it, I just don&#39;t what was th= e problem.</div><div><br></div>--=A0<br>Atenciosamente / Sincerely,<br>Guil= herme (&quot;n2liquid&quot;) Vieira<br> <br><div><br><div class=3D"gmail_quote">On Mon, Jan 10, 2011 at 1:25 AM, Se= an Eskapp <span dir=3D"ltr">&lt;<a href=3D"mailto:eatingstaples gmail.com">= eatingstaples gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail= _quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:= 1ex;"> I&#39;m trying to use the array() function in std.array to convert a transf= ormed<br> array using map (std.algorithm) back to a dynamic array, from a Map. I keep= <br> getting a cryptic error &quot;object.Exception C:\Program Files<br> (x86)\D\dmd2\windows\bin\..\..\src\phobos\std\<br> algorithm.d(426): Cannot reduce an empty range w/o an explicit seed value.&= quot;.<br> Am I misunderstanding how this is supposed to work?</blockquote></div> </div> --0016361e815ce70fcc0499855ee2--
Jan 10 2011
prev sibling parent "Daniel Murphy" <yebblies nospamgmail.com> writes:
"Sean Eskapp" <eatingstaples gmail.com> wrote in message 
news:igdu78$18kt$1 digitalmars.com...
 I'm trying to use the array() function in std.array to convert a 
 transformed
 array using map (std.algorithm) back to a dynamic array, from a Map. I 
 keep
 getting a cryptic error "object.Exception C:\Program Files
 (x86)\D\dmd2\windows\bin\..\..\src\phobos\std\
 algorithm.d(426): Cannot reduce an empty range w/o an explicit seed 
 value.".
 Am I misunderstanding how this is supposed to work?

You're calling reduce on an empty range. reduce!"a*b"([1, 2, 3]); // fine, translates to 1 * 2 * 3 reduce!"a*b"([7]); // also fine, translates to 7 reduce!"a*b"([]); // what should this be? Luckily you can call reduce with an extra argument giving the seed value: reduce!"a*b"(1, []); // Calculates product for both empty and non-empty ranges.
Jan 10 2011