Last active
August 29, 2015 14:02
-
-
Save KOUCHANG/ed31990f33cefb3c0431 to your computer and use it in GitHub Desktop.
Erlangの andalso は第2引数が boolean() じゃなくても良い ref: http://qiita.com/KOU_CHANG/items/a5c6bc7177976a8d8640
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1> true andalso false. | |
false | |
2> true andalso ok. | |
ok | |
3> false orelse true. | |
true | |
4> false orelse ok. | |
ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Expr1 orelse Expr2 | |
Expr1 andalso Expr2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4> true or garbage. | |
** exception error: bad argument | |
in operator or/2 | |
called as true or garbage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all(Pred, [Hd|Tail]) -> | |
Pred(Hd) andalso all(Pred, Tail); | |
all(_, []) -> | |
true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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