[erlang-questions] Tried this... Thought it interesting... But it didn't work.

zxq9 <>
Tue Sep 1 20:56:28 CEST 2015


On 2015年9月1日 火曜日 15:15:02 Fernando 'Brujo' Benavides wrote:
> We had this same discussion before with Jesper (when I wrote this blog post), but I still think these versions clearer:
> 
> remove_args(#state { contents = C } = State) ->
>     frequency(
>       case C of
>           [] -> [];
>           C -> [{5, ?LET(Pair, elements(C), [element(1, Pair)])}]
>       end ++ [{1,  ?SUCHTHAT([K], [map_key(State)], find(K, 1, C) == false)}]).
> 
> 
> f(X) -> [1,2,3] ++ e(X) ++ [4,5].
> e(X) when X > 5 -> [7];
> e(_) -> [].
> 
> My two cents, ¯\_(ツ)_/¯ 


...or this (though appending to the tail end of a case feels weird to me -- but it is instantly understandable). I would have spent a moment scratching my head at the original because I see it so rarely. Actually, the only times I've ever seen this have been this discussion and a similar discussion about coding anomalies a few months ago.

-Craig


More information about the erlang-questions mailing list