<br><br><div class="gmail_quote">On Tue, Jun 2, 2009 at 4:59 PM, Nico Rolle <span dir="ltr"><<a href="mailto:nrolle@web.de">nrolle@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
hi there<br>
<br>
heres a code snipped, don't care about the parameters.<br>
the thing is i make a lookup on my map "m" and then branch on that return value<br>
<br>
probePhase is sc [] m = []<br>
probePhase is sc (x:xs) m<br>
| val == Nothing = probePhase is sc xs m<br>
| otherwise = jr ++ probePhase is sc xs m<br>
where<br>
jr = joinTuples sc x (fromMaybe [] val)<br>
key = getPartialTuple is x<br>
val = Map.lookup key m</blockquote><div><br></div><div>Here's my take. This ought to be equivalent, but I haven't tested.</div><div><br></div><div>probePhase is sc m = concatMap prefix</div><div> where</div>
<div> prefix x = let key = getPartialTuple is x in</div><div> maybe [] (joinTuples sc x) $ Map.lookup key m</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
<br>
the line "jr = joinTuples sc x (fromMaybe [] val)" is kind of ugly<br>
because i know that it is not Nothing.<br>
is there a better way to solve this?<br>
regards<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>