<p dir="ltr">+1, but what's wrong with just</p>
<p dir="ltr">whatever::(a->Bool)->[a]->[a]</p>
<p dir="ltr">Is this some subtle efficiency thing relating to closure creation?</p>
<div class="gmail_quote">On Jun 21, 2015 2:32 AM, "Grant Slatton" <<a href="mailto:grantslatton@gmail.com">grantslatton@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8000001907349px">Right now the type of deleteBy is:</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">(a -> a -> Bool) -> a -> [a] -> [a]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">That is, it takes an equality predicate, a value, and a list, and deletes the first element in the list such that the equality predicate returns true for the given value and the element.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">This can be generalized to:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">(a -> b -> Bool) -> a -> [b] -> [b]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Example use case:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">keyValues :: [(a, b)]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">key :: a</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">deleteBy (\x (y, _) -> x == y) key keyValues</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Grant Slatton</div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div>