<div dir="ltr">Hey,<div><br></div><div>I'm getting some unexpected behavior when trying to pattern match the head of a list.</div><div><br></div><div style>When matching against a list of integers I can successfully do a wildcard match:</div>
<div>27> ("ab ++ _) = "abcd".<br></div><div><br></div><div style>But when trying to do the same with a list of atoms i get the error: * 1: illegal pattern:</div><div style><div>28> ([a,b,c] ++ _) = [a,b,c,d].</div>
<div>* 1: illegal pattern</div><div><br></div><div style>So just making sure there's no magic in string matching i also try with an actual list of integers:</div></div><div><div>29> ([0,1,2] ++ _) = [0,1,2,3,4]. </div>
<div>[0,1,2,3,4]</div></div><div><br></div><div style>Why can't I pattern match a lists with other values integers?</div><div><br></div><div>What i'm looking to achieve is to provide wildcard matching on a gen_event handler so I can do matches like this:</div>
<div><br></div><div style>handle_event((Match ++ _), State#state{match = Match}) -></div><div style>% handle</div><div style><br></div><div style>Any other alternatives is appreciated, current implementation uses lists:suffix/2</div>
<div><div><br></div>-- <br>Med Vennlig Hilsen<div>Olav Frengstad</div><div><br></div><div>Systemutvikler // FWT</div><div>+47 920 42 090</div>
</div></div>