Skip to content

Instantly share code, notes, and snippets.

@boorad
Created October 12, 2009 21:16
Show Gist options
  • Save boorad/208756 to your computer and use it in GitHub Desktop.
Save boorad/208756 to your computer and use it in GitHub Desktop.
final_key_lookup(Good, Bad, N, Const, ResolveFun, NotFoundFun, Access) ->
{NotFound, Reasons} = NotFoundFun(Bad, Const),
if
length(Good) >= Const -> {ok, ResolveFun(Good)};
NotFound -> {ok, not_found, Reasons};
true -> error_message(Good, Bad, N, Const, Access)
end.
% and
resolve_not_found(Bad, R) ->
{Count, Reasons} = lists:foldl(fun({Error,Reason}, {CountAcc,ReasonAcc}) ->
case Error of
not_found -> {CountAcc+1, [Reason|ReasonAcc]};
_ -> {CountAcc, ReasonAcc}
end
end, {0, []}, Bad),
if
Count >= R -> {true, Reasons};
true -> {false, Reasons}
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment