Skip to content

Instantly share code, notes, and snippets.

@yfyf
Created February 4, 2012 15:08
Show Gist options
  • Save yfyf/1738397 to your computer and use it in GitHub Desktop.
Save yfyf/1738397 to your computer and use it in GitHub Desktop.
motivation for the extended integers
Return = case NumberGrouping of
default ->
Nums = [Nr || {Nr, _} <- ctree:get_nr(ResultTree, [{count, Limit}])],
Sublist = case Limit of
infinity ->
Numbers;
L when is_integer(L) ->
lists:sublist(number_utils:expand_list(Nums), Limit)
end,
number_utils:reduce_list(Sublist).
aligned ->
Blocks = [Nr || {Nr, _} <- ctree:get_nr(ResultTree,
[{type, blocks}, {count, Limit}])],
BlockNumCount = number_utils:count_list(Blocks),
case Limit /= infinty andalso BlockNumCount >= Limit of
true ->
reduce_blocks_to_limit(Blocks, Limit);
false ->
Sparse = [Nr || {Nr, _} <- ctree:get_nr(ResultTree, [
{type, sparsed},
{count, (case Limit of
infinity ->
infinity;
_ ->
Limit - BlockNumCount
end)}
])],
lists:append(Blocks, Sparse)
end;
<..>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment