Skip to content

Instantly share code, notes, and snippets.

@KOUCHANG KOUCHANG/file0.erl
Last active Aug 29, 2015

Embed
What would you like to do?
Erlangの andalso は第2引数が boolean() じゃなくても良い ref: http://qiita.com/KOU_CHANG/items/a5c6bc7177976a8d8640
1> true andalso false.
false
2> true andalso ok.
ok
3> false orelse true.
true
4> false orelse ok.
ok
Expr1 orelse Expr2
Expr1 andalso Expr2
4> true or garbage.
** exception error: bad argument
in operator or/2
called as true or garbage
all(Pred, [Hd|Tail]) ->
Pred(Hd) andalso all(Pred, Tail);
all(_, []) ->
true.
get_value(Key, DefinedList) ->
case DefinedList =:= undefined orelse proplists:get_value(Key, DefinedList) of
{Key, Value} -> {ok, Value};
_ -> {error, not_match} %% NOT_MATCH_PROCESS
end.
get_value(_Key, undefined) ->
{error, not_match}; %% NOT_MATCH_PROCESS
get_value(Key, DefiendList) ->
case proplists:get_value(Key, DefinedList) of
{Key, Value} -> {ok, Value};
_ -> {error, not_match} %% NOT_MATCH_PROCESS
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.