Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generates a tuple of popcounts.
gen_table(Bits) -> gen_table(1, 2 bsl (Bits - 1), {0}).
gen_table(Stop, Stop, Table) -> Table;
gen_table(Value, Stop, Table) ->
New = (Value band 1) + erlang:element((Value bsr 1) + 1, Table),
NewTable = erlang:append_element(Table, New),
gen_table(Value + 1, Stop, NewTable).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.