riichi/src/lazy.erl
2013-06-14 23:43:46 -04:00

17 lines
291 B
Erlang

-module(lazy).
-export([find/2]).
-include("lazy.hrl").
find(Predicate, [H|T]) when is_function(H) ->
Value = ?FORCE(H),
case Predicate(Value) of
true ->
{ok, Value};
_ ->
find(Predicate, T)
end;
find(_Predicate, []) ->
undefined.