Well, in my mind the list comprehension goes through the statements performing a pattern match, performing an "and". This includes the extraction op ("<-"). So that would make sense in that context.<br>
The map() function takes a fun, where you'd of course get a function_clause mismatch.<br><br><br><div><span class="gmail_quote">On 8/8/06, <b class="gmail_sendername">Bengt Kleberg</b> <<a href="mailto:bengt.kleberg@ericsson.com">
bengt.kleberg@ericsson.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">greetings,<br><br>there is a difference between lists:map/2 and list comprehension that
<br>can hide errors in the code. the generator part works like a filter,<br>silently dropping unmatched items in the list. it would be nice if this<br>was mentioned in the documentation.<br><br><br>from the documentation and examples of list comprehension
<br>(<a href="http://www.erlang.se/doc/doc-5.5/doc/programming_examples/part_frame.html">http://www.erlang.se/doc/doc-5.5/doc/programming_examples/part_frame.html</a>)<br>i have assumed that the generator part works like the fun head in
<br>lists:map/2 (or lists:filter/2, etc).<br>ie the following two pices of code would be equivalent:<br><br>1) [A || {A, B, C} <- L].<br>2) lists:map( fun({A, B, C}) -> A end, L).<br><br>however, using the list L = [{a,b,c}, {1,2,3,4}].
<br>i get the following:<br>1) [a]<br>2) ** exited:<br>{function_clause,[{erl_eval,'-inside-a-shell-fun-',{{1,2,3,4}}},<br>                              {erl_eval,expr,3}]} **<br><br><br>bengt<br>--<br>    EPO guidelines 1978: "If the contribution to the known art resides
<br>    solely in a computer program then the subject matter is not<br>    patentable in whatever manner it may be presented in the claims."<br></blockquote></div><br>