<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="stockticker"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 77.95pt 1.0in 77.95pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Folks,<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>I defined a C++/<st1:stockticker w:st="on">CLI</st1:stockticker>
IEnumerator<KeyValuePair<int, double> > class (a sparse matrix
class).<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>When I use it in a comprehension(see below) IP seems to "automatically"
return only the value part of the KeyValuePair.<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>IronPython 1.0.2302 (Beta) on .<st1:stockticker w:st="on">NET</st1:stockticker>
2.0.50727.40<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>Copyright (c) Microsoft Corporation. All rights
reserved.<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> import ShoNS<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> sss = ShoNS.Array.SparseArray(1000, 1000,
1000)<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> sss[100, 10] = 1<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> sss[2, 10] = 2<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>## Test the IEnumerator directly ##<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> eee = sss.ColumnElements(10)<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> eee.MoveNext()<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>True<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> eee.Current<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>[100, 1]<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>## Type is right!! ##<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> type(eee.Current)<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'><type 'KeyValuePair`2'><o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>## Strange that this does not work ###<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> [s for s in sss.ColumnElements(10)]<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>[1.0, 2.0]<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>## Even worse, this is a bug!!! ##<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>> for s in sss.ColumnElements(10): print
s.Key, "->", s.Value<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>... <o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>Traceback (most recent call last):<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'> File , line 0, in input##203<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>AttributeError: 'float' object has no attribute 'Key'<o:p></o:p></span></font></p>
<p class=MsoPlainText style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt'>>>><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Thanks,<o:p></o:p></span></font></p>
<p class=MsoPlainText><st1:PersonName w:st="on"><font size=2 face="Courier New"><span
style='font-size:10.0pt'>Paul Viola</span></font></st1:PersonName><o:p></o:p></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Senior Researcher<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'>Microsoft Research<o:p></o:p></span></font></p>
<p class=MsoPlainText><font size=2 face="Courier New"><span style='font-size:
10.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>