Guest User

Untitled

a guest
Feb 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. %%%-------------------------------------------------------------------
  2. %%% @doc Simple pattern matching
  3. %%% @end
  4. %%%-------------------------------------------------------------------
  5. -module(boolean).
  6.  
  7. % Public API
  8. -export([b_not/1, b_and/2, b_or/2]).
  9.  
  10. %%--------------------------------------------------------------------
  11. %% @doc Operator 'not'.
  12. %% @end
  13. %%--------------------------------------------------------------------
  14. -spec b_not(Value :: boolean()) -> boolean().
  15. b_not(true) ->
  16. false;
  17. b_not(false) ->
  18. true.
  19.  
  20. %%--------------------------------------------------------------------
  21. %% @doc Operator 'and'.
  22. %% @end
  23. %%--------------------------------------------------------------------
  24. -spec b_and(Value1 :: boolean(),
  25. Value2 :: boolean()) -> boolean().
  26. b_and(true, true) ->
  27. true;
  28. b_and(Other, Another) when is_atom(Other), is_atom(Another) ->
  29. false.
  30.  
  31. %%--------------------------------------------------------------------
  32. %% @doc Operator 'or'.
  33. %% @end
  34. %%--------------------------------------------------------------------
  35. -spec b_or(Value1 :: boolean(),
  36. Value2 :: boolean()) -> atom().
  37. b_or(false, false) ->
  38. false;
  39. b_or(Other, Another) when is_boolean(Other), is_boolean(Another)->
  40. true.
Add Comment
Please, Sign In to add comment