<div dir="ltr">Thanks, Bjorn. Kind of a bummer -- but I'm having so much fun with the language to let these come in the way :).<div><br></div><div>Best,</div><div>Santosh<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 8:57 PM, Björn-Egil Dahlberg <span dir="ltr"><<a href="mailto:wallentin.dahlberg@gmail.com" target="_blank">wallentin.dahlberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Ah, when the book appears before the implementation .. or even the spec.</div><div><br></div>Only literal keys are allowed in Maps in the current release (17.0+). And with literals we mean no variables in this case.<div><br></div><div>In the master branch (18) we currently allow for variables but not as described in joes book (at least not yet). Variables has to be bound before they are used there.</div><div><br></div><div>// Björn-Egil</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2014-12-10 2:46 GMT+01:00 Santosh Kumar <span dir="ltr"><<a href="mailto:santosh79@gmail.com" target="_blank">santosh79@gmail.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><font face="verdana, sans-serif">Hi,</font><div><font face="verdana, sans-serif">Working my way through Joe's book and I have another issue with getting one of his code snippets to compile. Specifically, pattern matching within the args list of a function definition just isn't working. Here's the code:</font></div><div><br></div><div><div><font face="monospace">count_characters(Str) -></font></div><div><font face="monospace">     count_characters(Str, #{}).</font></div><div><font face="monospace">count_characters([H|T], #{ H => N }=X) -></font></div><div><font face="monospace">     count_characters(T, X#{ H := N+1 });</font></div><div><font face="monospace">count_characters([H|T], X) -></font></div><div><font face="monospace">     count_characters(T, X#{ H => 1 });</font></div><div><font face="monospace">count_characters([], X) -></font></div><div><font face="monospace">     X.</font></div></div><div><br></div><div><font face="verdana, sans-serif">It's not liking the variable binding of 'H'. So if I do something like so, it's not "evaluating" the bound value in a map.</font></div><div><br></div><div><p style="margin:0px"><font face="monospace">39> Henry8.</font></p>
<p style="margin:0px"><font face="monospace">#{born => 1491,class => king,died => 1547}</font></p><p style="margin:0px"><font face="monospace">42> B = born.</font></p><p style="margin:0px"><font face="monospace">born</font></p><p style="margin:0px"><font face="monospace">43> #{B := HB} = Henry8.</font></p><p style="margin:0px">


</p><p style="margin:0px"><font face="monospace">* 1: illegal use of variable 'B' in map</font></p><p style="margin:0px;font-size:15px;font-family:Menlo"><br></p><p style="margin:0px"><font face="verdana, sans-serif">Any help is much appreciated</font><span style="font-family:Menlo">.</span></p><p style="margin:0px;font-family:Menlo"><br></p><p style="margin:0px;font-family:Menlo">Thanks</p><span><font color="#888888"><p style="margin:0px;font-family:Menlo">Santosh</p></font></span></div></div>
<br></div></div>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>