[erlang-questions] {some,term} = [] ++ {some, term}.
Pierre Fenoll
pierrefenoll@REDACTED
Tue Apr 24 18:19:06 CEST 2018
Another funny thing:
1> {A,B} = {sets:from_list([-28]), sets:from_list([4])}.
{{set,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],[],[],[],[],[],[],[],[],[-28],[],[],[]}}},
{set,1,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],[],[],[],[],[],[],[],[],[],[],[4],[],[],[]}}}}
2> sets:union(A,B) == sets:union(B,A).
false
Thomas Arts (of QuickCheck fame) showed this in 2005 I think!
This is due to the sets underlying representation.
I thought there was a PR to use maps instead but can't find it anymore.
The corresponding PropEr property:
-include_lib("proper/include/proper.hrl").
a_sets_generator() ->
?LET(SomeList, list(integer())
,sets:from_list(SomeList)
).
%% rebar3 as test proper -p prop_sets_union_is_commutative
prop_sets_union_is_commutative() ->
?FORALL({SetA,SetB}, {a_sets_generator(),a_sets_generator()}
,?WHENFAIL(io:format("\nSetA = ~w\nSetB = ~w\n",
[sets:to_list(SetA), sets:to_list(SetB)])
,sets:union(SetA,SetB) =:= sets:union(SetB,SetA)
)
).
Cheers,
--
Pierre Fenoll
On 24 April 2018 at 17:15, Brujo Benavides <elbrujohalcon@REDACTED> wrote:
> Hi John,
>
> See here: https://medium.com/erlang-battleground/the-
> asymmetry-of-validations-1ccdf2457293
>
> Hope this helps :)
>
> ------------------------------
> *Brujo Benavides <http://about.me/elbrujohalcon>*
>
>
>
> On 24 Apr 2018, at 12:13, John Doe <donpedrothird@REDACTED> wrote:
>
> Hi,
> is this normal?
>
> {some,term} = [] ++ {some, term}. %% list vanishes
>
> [1,2,3|{some,term}] = [1,2,3] ++ {some, term}. %% improper list
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180424/db09928a/attachment.htm>
More information about the erlang-questions
mailing list