Skip to content

Instantly share code, notes, and snippets.

@puzza007
Forked from mietek/or_or_or.erl
Last active December 27, 2015 12:29
Show Gist options
  • Save puzza007/7326351 to your computer and use it in GitHub Desktop.
Save puzza007/7326351 to your computer and use it in GitHub Desktop.
-module(or_or_or).
-compile(export_all).
f1(X) ->
if
length(X) =:= 1; size(X) =:= 1 ->
okay;
true ->
nope
end.
f2(X) ->
if
length(X) =:= 1 orelse size(X) =:= 1 ->
okay;
true ->
nope
end.
test() ->
io:format("f1([x]) = ~p~n", [f1([x])]),
io:format("f1({x}) = ~p~n", [f1({x})]),
io:format("~n", []),
io:format("f2([x]) = ~p~n", [f2([x])]),
io:format("f2({x}) = ~p~n", [f2({x})]).
puzza@Pauls-MacBookPro /tmp $ erl
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.3 (abort with ^G)
1> or_or_or:test().
f1([x]) = okay
f1({x}) = okay
f2([x]) = okay
f2({x}) = nope
ok
2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment