riichi/src/lazy.erl

18 lines
291 B
Erlang
Raw Normal View History

2013-06-15 03:43:46 +00:00
-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.