<div dir="ltr"><span id="docs-internal-guid-01346169-8dcc-a9cf-7fed-432f7aa17a5a"><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">I just watched Kenneth’s map talk from the EUC (<a href="http://vimeo.com/99747090">http://vimeo.com/99747090</a>).  He asked for feedback on maps, so here’s mine:</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">1. I ported a few functions from the lists module.  The ones I found useful were filter() and mapfold().  I also found with() useful, which does the opposite of maps:without().  I would be very happy to see these 3 functions in the maps module.</span></p>
<br><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">2. In the talk there was a question about matching an empty map, and also a question about precise matching like how one would match a list.  I have always wondered similar things, so it got me thinking…</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">What if we use a "cons" in a map pattern to allow matching all remaining keys that were not selected in the main part of the pattern?  This would be roughly symmetric to what you can do with lists and binaries.  For example:</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">#{ a:=A, c:=C | Rest } = #{a=>1, b=>2, c=>3, d=>4}.   % Rest = #{b=>2, d=>4}</span></p>
<div><span><br></span></div><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">That in itself I think has limited use, but it could be used to exactly match a map (ie, no extra pairs other than those specified in the match):</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">f(#{ a:=A, c:=C | Rest })</span></p>
<p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">   when maps:size(Rest)==0 -></span></p>
<p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">…</span></p>
<div><span><br></span></div><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">If the pattern to the right of the bar is elided, we could take it to mean “match the empty map”.  The previous example could be rewritten as:</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">f(#{ a:=A, c:=C |}) -></span></p>
<p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">…</span></p>
<div><span><br></span></div><br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">This also lets you match just the empty map as was asked in the talk:</span></p>
<br><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">f(#{|}) -></span></p>
<p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:'Courier New';color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">…</span></p>
<div><span><br></span></div><div><span><br></span></div><div><span><br></span></div>Apologies if something like this has already been discussed.<br><br>Dan.</span></div>