[erlang-questions] {some,term} = [] ++ {some, term}.

Brujo Benavides elbrujohalcon@REDACTED
Tue Apr 24 18:35:40 CEST 2018


Maybe sets could provide a function like…

is_equal(A, B) -> is_subset(A, B) andalso is_subset(B, A).

Brujo Benavides <http://about.me/elbrujohalcon>



> On 24 Apr 2018, at 13:19, Pierre Fenoll <pierrefenoll@REDACTED> wrote:
> 
> 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 <mailto:elbrujohalcon@REDACTED>> wrote:
> Hi John,
> 
> 	See here: https://medium.com/erlang-battleground/the-asymmetry-of-validations-1ccdf2457293 <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 <mailto: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 <mailto:erlang-questions@REDACTED>
>> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> http://erlang.org/mailman/listinfo/erlang-questions <http://erlang.org/mailman/listinfo/erlang-questions>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180424/e9387de5/attachment.htm>


More information about the erlang-questions mailing list